250 Hello

Random Musings on Exchange and Virtualization

PowerShell Resources For The Exchange Administrator

PowerShell Resources For The Exchange Administrator

  • Comments 4
  • Likes

A long time ago, in a continent far, far away from where I currently live….

 

There was a younger, fitter and better looking version of me.   One of the few woes that this chap had, was that on a Friday afternoon he would be struggling to delete enough files off a server to allow that day’s event log archive process to run.  Site Server 3.0 ( yes, I’m really dating myself now….) was used to replicate the DMZ logs to the archive server as it meant only a single TCP port had to be punched in the firewall.  That  was great.  What was not so great was that it used an Access database engine to keep track of what it had replicated and what could then be deleted.  The deletion process often failed leaving thousands of unwanted files behind on the staging server.  It was these pesky remnants which stood between that younger version of me and a pint of Staropramen

 

So you can see the motivation.  Stay behind for hours manually truffling through thousands of directories trying to delete old files, or learn to script….

 

It came to pass that I got down and dirty with VBScript.  Yes I could have done this using cmd, but VBScript was new and shiny, and also was something neat to learn!  This helped bring balance to the force, and was also excellent at providing repeatable process to implement IT tasks.  This included IIS ADSI modification scripts, AD user provisioning and also for Exchange 2000/2003 tasks.

 

VBScript was one of the main automation tools for Exchange 2003.  It worked well, but you had to do pretty much everything yourself.

Want a function to search for a mailbox.  No problem, just code it from scratch.

Want to add a recursive search to the above function.  No problem, just code it from scratch.

 

PowerShell changed the game with Exchange 2007, and it became the weapon of choice.  At last, simple things became simple tasks.

Want to see properties for a mailbox.  No problem, just run Get-Mailbox

Want to add a recursive search.  No problem, just add –Recurse.

 

 

Enough preamble – what’s this page for?  I wanted to have a single place where I could aggregate links and other content that I could then easily refer back to.  It is work in progress, and will change/evolve over time. I will try and post samples where possible to the TechNet galleries and link back to here.

 

Please do add a comment if there is something that you’d like to see added here!

 

 

Introduction To PowerShell For the Exchange Admin

This is a series of articles that I previously wrote.  They discuss changes to scripting Exchange from 2003 to Exchange 2007/2010.   Part 2 has a detailed breakdown of the mechanics involved in Exchange 2010’s remote PowerShell

Part 1

Part 2

Part 3

 

Other PowerShell Articles On This Blog

image

In addition to the articles mentioned above, there are other items that I have written with touch upon PowerShell.  While this may be from a Windows platform perspective, they are still very useful.  The easiest way is to list all articles that have a PowerShell tag.

 

Alternatively use the search tool on the right.

 

Articles with PowerShell tag. 

Built-In Help

PowerShell is self describing in that you can use PowerShell to find out more about PowerShell.  This was covered in the Introduction article using the Get-Member cmdlet.  Additionally we can also use Get-Help to retrieve extra information.

PowerShell Get-Help About_*

On this Windows 2008 R2 SP1 server, this returned 89 items.  How do I know 89?  I’m too lazy to count, so I just pipe to Measure-Object.

For example if you want to know the format of PowerShell’s FOR loop, simply run:

Get-Help about_for

TechNet Wiki

There is a good page on TechNet with additional links

Exchange 2010 PowerShell Scripting Resources

VBScript To PowerShell Conversion Guide

For those who still think, in VBScript and then have to convert to PowerShell this is for you.  And yes, I still have a habit of thinking of VBScript syntax…

 

 

For convenience, I have extracted the file from the bundle and you can download it from here directly.

 

General PowerShell Getting Started Guides

 

Blog Links

Pat Richards – lots of one liner examples

Shay Levy – This post for Windows Live Writer formatting is interesting

Development Resources

Glen Scales Exchange Dev Blog – well worth a read!

 

Additional Resources

  • Windows PowerShell Team Blog. The best resource for learning directly from the Windows PowerShell product team.
  • Windows PowerShell Customer Connection. Make a suggestion, send feedback, or file a bug for the Windows PowerShell team. You can file a code bug, a documentation bug, or a localization (language translation) bug.
  • The Hey, Scripting Guy! Blog publishes new content seven days a week, and is consistently ranked in the top five of all Microsoft blogs. The articles are scenario-driven, and written in an engaging and lively manner.
  • The Learn PowerShell page is the Windows PowerShell hub on the TechNet Script Centre.

 

 

 

 

Cheers,

Rhoderick

 

Can You Help Us?  -- Yes !

If you would like to have Microsoft Premier Field Engineering (PFE) visit your company and assist with the topic(s) presented in this blog post, then please contact your Microsoft Premier Technical Account Manager (TAM) for more information on scheduling and our varied offerings!

If you are not currently benefiting from Microsoft Premier support and you’d like more information about Premier, please email the appropriate contact below, and tell them you how you got introduced!

US

Canada

For all other areas please use the US contact point.





Comments
  • This will be a great resource to share with others, Thank You!

  • Nice logon name, I see what you did there :)

    As always, if you have suggestions please do let me know.

    Cheers,

    Rhoderick

  • Great article.  Hope you don't mind me hijacking it with this query:

    I'm migrating a customer from their hosting environment (Ex2010) to on-premise (Ex2013).

    I need to recreate from scratch the target infrastructure. Fun.

    I have a CSV which contains data for the following lines.  

    SamAccountName,PrimarySMTPAddress,EmailAddresses,FirstName,LastName,HomePhone,MobilePhone,Phone,Company,Title,Department,Office,UserPrincipalName,ForwardingSMTPAddress,FullAccess,SendAs,SendOnBehalf

    How can i CREATE new mailboxes for these people with ALL this data (or as close as possible) in order to populate the GAL etc?  Can it be done with one CSV???  They already have EXISTING AD accounts.

    Any help greatly appreciated.

  • Very much doable :)

    The cmdlet we need is Enable-Mailbox

    Import-CSV will read in the contents of the CSV, and then its a matter of aligning values to be passed to enable-mailbox.  

    Try this for example

    Import-Csv .\list.csv  | ForEach {Enable-Mailbox -Identity $_.SamAccountName -PrimarySmtpAddress $_.PrimarySMTPAddress}

    You can do the same thing for set-user to get AD populated with all the necessary data.

    Cheers,

    Rhoderick

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
Post Comment Fixer