August 22, 2006

How to programatically mail-enable an Exchange public folder

KC http://blogs.technet.com/kclemson/archive/2006/08/21/448401.aspx on her blog: set two attributes via MAPI and you're done.

Posted by Paul at 11:24 AM | Comments (0)

July 11, 2006

Script to find EDB and STM file sizes

Michael B. Smith posted a cool script on his blog today: it finds all the EDB and STM files on Exchange servers in your organization, then tells you how much disk space they actually take up. If you've ever wondered how much disk space your Exchange data is consuming, now you can find out.

Posted by Paul at 03:29 PM | Comments (0)

May 11, 2006

Finding and removing empty DLs

From prolific Exchange MVP Glen Scales, this script will identify empty DLs or DGs and let you remove them.

Posted by Paul at 06:01 PM | Comments (0) | TrackBack

May 10, 2006

Bulk-enabling or disabling Outlook Mobile Access users

From TechTarget's Exchange Tips web site, this script lets you enable or disable OMA for multiple users at once.

Posted by Paul at 09:54 PM | Comments (0) | TrackBack

April 21, 2006

Monad event log monitoring

The Monad team blog has a useful Monad script for intelligent event log analysis. The simple way to do it is to say

get-eventlog Application | where {$_.EventID -eq -1018}

but this gets the same set of events every time you run it. The team's script uses a checkpoint file to keep track of the last search it did, and it has a few other nice features as well.

Posted by Paul at 05:46 AM | Comments (0)

April 12, 2006

Find store GUIDs

From new Exchange MVP Bharat Suneja: a script to find the GUID for a mailbox database. You need this if you want to raise the size limit for a store in the Standard Edition of Exchange.

Posted by Paul at 05:05 PM | Comments (0)

October 06, 2005

Enabling and disabling MAPI, POP, IMAP, or HTTP

I get asked this all the time, and I keep meaning to write a script for it. In fact, this is really just a placeholder for the "Exchange Security Tips and Tricks" session I'm doing at Exchange Connections. Glen Scales explains how to stamp protocolSettings for controlling IMAP and POP access in this script. I need to clean it up and add MAPI support sometime before the Connections show starts :)

Posted by Paul at 10:41 AM | Comments (3)

October 03, 2005

Sending a welcome email to newly created users

Mike Ruman of Grant Thornton LLP sent me this cool script: it selects all the users created today and sends them a welcome message. You'll need to edit it to reflect your own domain information, as well as the contents of the message you want to send.

'Created by Mike Ruman 8/13/05
'Sends an email to accounts created today.

Dim StrDate, CurrentUTC

'Create the current date and time stamp for query for day before last
CurrentUTC = DatePart("yyyy", Date)
'now add Month in mm if only M add leading 0
if DatePart("m" , Now) < 10 then
CurrentUTC = CurrentUTC & 0 & DatePart("m" , Now)
else
CurrentUTC = CurrentUTC & DatePart("m" , Now)
end if
'now add Day in dd if only d add leading 0
if DatePart("d" , Now) < 10 then
'OPTIONAL - FOR MANY DAYS, replace line below with CurrentUTC = CurrentUTC & 0 & DatePart("d" , Now - X) where X = # of days

CurrentUTC = CurrentUTC & 0 & DatePart("d" , Now)
else
'OPTIONAL - FOR MANY DAYS, replace line below with CurrentUTC = CurrentUTC & DatePart("d" , Now - X) where X = # of days
CurrentUTC = CurrentUTC & DatePart("d" , Now)
end if
' Tag hour, minute, second on
strDate = CurrentUTC&"000001.0Z"

'Create AD Connection
Set oConnection1 = CreateObject("ADODB.Connection")
Set oCommand1 = CreateObject("ADODB.Command")
oConnection1.Provider = "ADsDSOObject" ' This is the ADSI OLE-DB provider name
oConnection1.Open "Active Directory Provider"
' Create a command object for this connection.
Set oCommand1.ActiveConnection = oConnection1
'Set Query definition

oCommand1.CommandText = "select mail from 'LDAP://DC=Fabrikam, DC=com' WHERE objectCategory='Person' AND objectClass='user'AND msExchHideFromAddressLists<>'True' AND whenCreated>='" & strDate & "'"

oCommand1.Properties("Page Size") = 30000
' Execute the query.
Set rs = oCommand1.Execute

rs.movefirst
'Create the loop of results
Do Until rs.EOF = True

'Create Email
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "Admin@fabrikam.com"
objEmail.To = rs.Fields("mail")
'Optional BCC field
'objEmail.BCC = "Admin@fabrikam.com"
objEmail.Subject = "A welcome message from Exchange"
objEmail.HTMLbody = "Welcome to Fabrikam. Please click on the attached file for a message."

'Optional Add an attachment
objEmail.AddAttachment "C:\new_hire_audio_message.wav"

objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing ") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver ") = _
"ExchangeServer" 'Replace ExchangeServer with server IP or name
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport ") = 25
objEmail.Configuration.Fields.Update

'Optional - Read the message before it's sent
'MsgBox objEmail.GetStream.ReadText
objEmail.Send
rs.movenext
Loop

'Close AD Connection
oConnection1.close

Posted by Paul at 06:00 AM | Comments (3)

September 19, 2005

Sending mail to users whose password's about to expire

Fellow MVP (and soon-to-be-published author of Essential Exchange Server 2003) Michael Smith has a cool script that will automatically send warning mail to users whose passwords are about to expire. Run it daily, and your mail-only users will never again be able to complain that their passwords expired without prior notice.

Posted by Paul at 05:14 AM | Comments (3)

September 16, 2005

Script for searching mailboxes for specified attachments

Here's a handy script I found while looking for something else: it searches all folders in a user's mailbox (to which you must have permissions, natch), scanning for attachments with a particular filename pattern.

Posted by Paul at 02:27 PM | Comments (0)

September 15, 2005

Setting default permissions on calendars

Let's say you wanted to set every calendar in your organization to grant all users "reviewer" rights. This makes it easy to see detailed calendar data instead of just pure free/busy information. There's no direct way to do this through CDOEXM or WMI, but Glen Scales has come up with a solution that uses the Exchange 5.5 acl.dll. Check it out here.

Posted by Paul at 11:28 AM | Comments (0)

August 18, 2005

Sending email via scripts

One common question I get is how to send email via scripts; Joseph Neubauer wrote a good article that explains how to do it using various dialects of CDO, as well as the SMTP pickup directory.

Posted by Paul at 07:25 AM | Comments (1)

August 09, 2005

Chapter 9 scripts

Chapter 9 tells you how to manage your public folder databases. Scripts in this chapter include:

Or you can get all of the chapter scripts as a single bundle.

In addition, this chapter is the sample chapter that you can download from O'Reilly's Exchange Server Cookbook page, so if you haven't actually seen the book yet, go there and take a look.

Posted by Paul at 11:28 AM | Comments (2) | TrackBack

July 25, 2005

Chapter 6 scripts

Chapter 6 is about managing mailbox and public folder databases. Scripts in this chapter include:

Or you can get all of the chapter scripts as a single bundle.

Posted by Paul at 10:12 AM | Comments (2) | TrackBack

July 20, 2005

Cool script: flip RPC-over-HTTP heuristic bits

Evan posted about this last month year, and I'm just now getting caught up. With Exchange 2003 SP1, you can use the new ESM UI to set up RPC over HTTPS, which is about a million times easier than the RTM way of doing so. However, you have to set up all your BE servers first, because the FEs will scan AD for the heuristic bits that indicate whether the BE is part of a managed topology or not. Problem: you have to set this manually on every BE, and you'd better not miss any! Solution: use this script to do all the work for you.

Posted by Paul at 04:48 PM | Comments (1) | TrackBack

July 18, 2005

Cool Exchange backup script

John Howard posted a nifty script for backing up Exchange servers.

Posted by Paul at 09:03 PM | Comments (0) | TrackBack

June 29, 2005

Chapter 8 scripts

Chapter 8 covers configuring Exchange for use with Outlook, OWA, OMA, and Internet clients. Scripts in this chapter include:

Or you can get this chapter's scripts as a single bundle.

Posted by Paul at 07:23 AM | Comments (0)

June 21, 2005

Chapter 7 scripts, reloaded

Hold the phone! You can't have a chapter about SMTP configuration without scripts, Though there were fewer scripts in this chapter than I would have liked to see, we still had them. Scripts in this chapter include:

Or you can get 'em as a single bundle.

There's one other recipe in this chapter (7.21, Setting IP Address Restrictions for Multiple Servers) that really should have a script, but the command-line tools turns out to be a combination of COM object and VBScript already. Rather than duplicate effort, we figured you could just look at the included script if you need to write your own, since you'll need the COM object from this tool anyway.

Posted by Devin Ganger at 11:34 AM | Comments (3)

June 16, 2005

Chapter 7 scripts

Chapter 7 covers SMTP configuration in great detail. Unfortunately, there aren't any scripts for this chapter I'm a moron and forgot to link to the scripts. They're here.

Posted by Paul at 06:02 PM | Comments (0)

Chapter 5 scripts

Chapter 5 is all about mailbox and recipient management. Scripts in this chapter include:

Or you can get 'em as a single bundle.

Posted by Paul at 05:58 PM | Comments (2)

Chapter 4 scripts

Chapter 4, Exchange Server and Organization Management, discusses the common management tasks associated with managing servers and organizational settings. Scripts in this chapter include:

Or you can get 'em as a single bundle.

Posted by Paul at 05:07 PM | Comments (0)

Scripts from Chapter 3

Chapter 3, Active Directory Integration, describes how Exchange talks to and uses Active Directory. Scripts in this chapter include:

Or you can get 'em as a single bundle.

Posted by Paul at 04:46 PM | Comments (2)

Scripts from Chapter 2

Chapter 2, Installation and Infrastructure, contains several useful scripts, which finally got posted as a bundle! You can also grab the individual scripts:

Update: fixed the broken links that Tom pointed out. Thanks, Tom!

Posted by Paul at 04:41 PM | Comments (6) | TrackBack

March 10, 2005

Scripts: coming very soon

We're in the last push to get the book finished. Part of that is that I'm making one last test and cleanup pass on the scripts. As I get them done, I'll post them here in the "Scripts" category... but to give you a reason to come back, I'll post one per day. Each chapter will have a post that lists the scripts in it, so you can see what's coming and when.

Posted by Paul at 10:26 AM | Comments (0)

January 06, 2005

Setting public folder permissions programmatically

For Chapter 9 of the cookbook, I needed a way to set public folder permissions from a script. The best answer I've found so far is Eric Legault's script, but it was too long and complex to include in the book. Rather than copy the script here, let me just refer you to it: Accessing Public Folder Permissions Programmatically.

Posted by Paul at 01:56 PM | Comments (1)

March 31, 2004

And now for a completely different kind of script…

I frequently work on a Mac running Mac OS X. I needed a way to grab the current open document in Word and attach it to the current message in Entourage (Microsoft's equivalent of Outlook for the Mac). This turned out to be a fairly simple task in AppleScript, which I don't savvy at all. Here's what I came up with:


tell application "Microsoft Word"
set attachName to full name of active document
if attachName is {} then return
end tell

tell application "Microsoft Entourage"
set newMsg to window 1
if class of newMsg ≠ draft window then return
make new attachment at newMsg with properties {file:attachName}
end tell

It's pretty simple: get the active Word document if one exists and tack it onto the frontmost draft message window in Entourage. It could undoubtedly be improved, but as is it's pretty useful. I'll probably use this almost as much as the "dial the phone number of the selected contact" script I snagged from  Simon Dorfman.

Posted by Paul at 01:31 PM | Comments (0)