Skip to main content

Posts

Showing posts from 2006

Quick Create Mailbox Powershell Form for Exchange 2007

A lot of times when your evaluating or testing code you may want to create some temporary mailboxes very quickly to test this or that. In Exchange 2007 the Exchange Command Shell’s new-mailbox commandlet gives a quick way of doing this. But because of the complexities of actually creating a mailbox eg knowing the Conical name of the OU and the name of the database you want to put it into etc actually typing all these values isn’t a fast or easy task. If your scripting this its not such a big deal because when your creating the script you can just cut and paste the values into your script and then you can run the thing a number of times and not have to worry about it. The Exchange Management Console provides wizards to create a mailbox but like all wizards they are designed to be easy to use not fast. So what I decided to do was see if I could put together a small 1 page form that you could run from the Exchange Command shell that would allow me to quickly put in the information that I...

Scripting Exchange Web Services (2007) with VBS and Powershell

I’ve been playing around with the new Exchange 2007 Web Services and thought I would share a few scripts. With a lot of API’s being deemphasized or disappearing completely in Exchange 2007, Exchange Web Services are the brave new world that confronts people who want to develop applications that run against an Exchange 2007 server. Like any other WebService EWS allows you to invoke different methods which will perform specific tasks by sending SOAP messages that contain certain properties and then receiving specifically formatted responses. For a scripting point of view it’s pretty easy firstly you need to authenticate the default authentication is NTLM so there is no need to worry about FBA synthetic logons and then it’s just a matter of posting a XML formatted SOAP message. If your familiar with using WebDAV the underlying methods you use are the same but the requests and responses are very different. Lets start with a simple send email example. smSoapMessage = "<?xml versio...

Exchange SMTP Log file DNS Test tool Powershell script

This powershell script is a combination of some of my past scripts (in particular the DNS util script ) wrapped up in a nice little GUI with buttons to make it easy to use on a daily basis. What this script does is allows you to open a SMTP log file (or if you don’t want to read the whole log file just a certain number of lines from a file) and it will then parse that log file into a DataGrid on a Winform. You can then select a line in the datagrid and use one of the Buttons provided to perform different DNS test on that log file entry. The tests it can do are Reverse DNS query on the Source Mail server IP Address (from the log file) MX lookup of the parsed domain name from a RCPT or MAIL SMTP command SPF lookup of the parsed domain name from a RCPT or MAIL SMTP command A Record lookup of the parsed domain name from a RCPT or MAIL SMTP command RBL lookup of Source Mail Server IP Address (Using SORB’s or any other RBL you like). To configure which RBL server to use you need to modify th...

Reporting on the age of content in mailbox folders and across an Exchange Server via a script

Like many of us the age of the content in mailboxes is constantly aging the usefulness of aged content on expensive storage is an always a elemental question for those people who are grasping at trying to manage mail-store usage. If your still running Exchange 2000 then you maybe battling with a very finite amount of storage asking your service provider to please make it last another six months (why me!!). So if this is the case you need to arm your users (and yourself) with maybe a little more information about where the storage in your mailboxes is being used and where the growth curves have happened over the years they have been commanding the storage in their mailbox. So enter this script, what this script does is scans every single item in a mailbox and looks at the creation date of this item. It then aggregates the size of the item and the item count into one of 3 categories 0-1 year old , 1-2 years old and over 2 years old. The script then produces a little html report that sho...

Creating a Server Side rule to move suspect messages with inline gifs to another folder using Rule.dll

Recently there has been a large increase in the amount of image based spam being sent out and also an increase in the amount of SPAM making it though SPAM filters because of the methods being employed such as randomizing images and also modifying images so they are difficult for any OCR based spam filter to decode the text. Stopping this at Edge device is the ultimate goal of any decent Sys Admin but this continuing war between spammers and those that create the software that can fight spam (and the accountants that stop us buying said software) means that we have to deal with the stuff that makes it though any defenses we might have and the inevitable complaints from the end users that stem from this. I decided to see if I could make a rule that at least could move any of these image based emails into a separate folder mainly for my postmaster account which tends to get hammered. Analyzing the basic image based spam message it consists of one inline gif image and a bunch of text. So ...

Geolocationing Exchange Message Tracking with Powershell (Exchange 2000/2003) (Seeing what countries your messages/Spam are coming from)

Geolocation as wikipedia aptly puts is the real-world geographic location of a computer based on its IP address. Many people use this for web site statistics for displaying where users are coming from. This information can also be very useful to actually tell you where your mail (and SPAM) is coming from. There are a lot of people out there selling and open sourcing geoip services, for instance awstats uses one of the open source variants to get the country information it uses in its report. Following some of these trails I found references to the IpToCountry.csv file which is a list of IP ranges per country that a few people maintain and provide (in slightly differing formats) for free as a download. The most up to date version in the one provided by Webnet77 which is the one I choose to use and is what this script is based on. Using this CSV file in its native format while possible with a little manipulation using the Microsoft text driver I found was very slow when trying to reso...

Showing which mailboxes have been enabled with Outlook Direct Booking via a script

Outlook direct booking is one of the many ways in which you can handle resource mailboxes in Exchange for a full list of other methods have a look at slipstick . Knowing which mailboxes have been enabled in your Exchange Organization could be a little tricky to keep a track of if you have a large number of mailboxes. One method of finding what mailboxes are using Direct booking is by using the freebusy data on a server. How Free-Busy data works and is stored is documented on Technet and this post on the Exchange Team Blog . The Free Busy data also comes into to play with Outlook Direct booking. When a user configures direct booking via the 3 check boxes under resource scheduling in Outlook – Calendar options there are 3 Mapi properties that get set on the local freebusy object in a mailbox. (Note this is not the only thing that happens you do enable direct booking permissions are also modified on the calendar and freebusy object in the resource mailbox) Automatically accept meeting a...

Creating a Domain based auto response rule using rule.dll

Somebody asked last week about creating a personalized auto response message based on the sender domain. While this would be pretty easy to do with a normal store based event sink another option you can use is to create a server side rule using the rule.dll. The script to do this is pretty basic there are numerous samples that show how to create a rule that will process mail based on a string in the subject field. Well all you really need to do is take that same logic and apply it to the sender address instead. So you basically end up with a rule that does a substring on the sender address looking for in this case a particular email domain and then use the Reply action which creates a normal automatic reply email using the text you configure. To use the script just configure the following line with the domain you want to use importPropVal.Value = "@domain.com” And this line with the text to respond with objReplyMsg.Text = "Im Sorry this Mailbox isn't currently maned fo...

Counting the number and type of Members in a Distribution list / Group via a script

A couple of months back I posted this script that would detect any empty distribution groups and give you the chance to delete them. Another useful thing to do now and again when your examining distribution lists in your Exchange organization is to look at how many members each group has and also what type of objects are members of certain lists. In Exchange apart from just user mailboxes you may have contacts (both internal and external), nested groups, Query based distribution lists or even public folders that are members of a distribution list. So its possible that some lists may have collected unwanted baggage in the normal course of events. So what I’ve done is come up with 3 different scripts for counting members based on the type of member of each distribution list and then generating a little html report to show the number of each type of object within each distribution list. The first script just does a basic count of the members of each list the second expands any nested gro...

BYO Message Tracking Center with PowerShell

One of the things I blog and create a lot of scripts for is message tracking there is so much good information stored in the Message Tracking Logs once you can pull it out and start doing things beyond what the Message Tracking Center can do in ESM. With the ability to access and manipulate WinForms like proper .net applications and also access WMI information you can with a little effort build your own replacement to the normal Message Tracking Center in ESM with a powershell script that will give you a pretty GUI based front-end that even your average Admin should be able to get their head around. And the really cool thing is you can start doing a lot more with the data that you’re mining such as aggregation. By this I mean grouping the number of emails by size and number to alllow you to see trends such as who is sending the most email, who's recieving the most email, how much data is being send and recieved from each email domain and also how much email was sent on a particula...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.