Powershell Script to create new user, enable for Exchange, UM and Lync Server

I created this powershell for our internal onboarding process, figured I would share it with the masses.

I think there are a couple good takeways from this script, it remotes into Exchange 2010 and Lync Server 2010 Powershell sessions, so nothing except Powershell 2.0 is required on the client side, which is standard with Windows 7. It also shows how you can simultaneously use Exchange and Lync powershell commands in the same script to get things done.

A couple of disclaimers:

I am in no way advanced at powershell scripting, so nothing fancy here.

This was developed specifically for my internal needs, you will probably have to add/remove variables and requirements.



Script is above, any freedback is appreciated, if you improve on this at all, I would love to see it as well.

About Randy Wintle

Unified Communications Architect

Posted on October 20, 2010, in Enterprise Voice, Exchange 2007, Exchange 2010, Exchange UM, Lync, Lync RC, Microsoft, OCS, OCS 2007 R2, Unified Communications. Bookmark the permalink. 9 Comments.

  1. You have got to just love Lync PS…my 2007 R2 script that did the same thing is like 10x longer than this…

    One thing, if you specify the target domain controller (-domaincontroller) for all of the cmdlets, I think you can dispense with the pauses in your script.

    • Thanks man, I tried that for some, but still had delays.

      The biggest delay is post mailbox creation, and then post lync enable. Time for lync database to update was always random.

      Worth a shot either way, keeps things consistent.

      • I believe that with the new Lync data store. When I get back to my environment I’ll see if I can fiddle with it. The ones I had done before had assumed mailbox creation ahead of time (customers already had a way in place to provision users and mailboxes), just UM/OCS enabling them, so I can also see mailbox creation taking too long for PS the execute the next command clean. I’ve done a lot of stuff with PowershellASP, which just can’t tolerate pauses – so I always try to avoid them if possible.

  2. Awesome Randy!

    Is there a way for us to create a CSV file and pump that into this script instead of having to type in the info manually?

    • Randy Wintle

      Yes, if you look in the powershell script where the prompts are occuring.

      You will see it is storing variables.

      You could easily comment out the prompts and instead do an import-CSV.

      The CSV File would need to have columns with each of those variables, and the variables would have to change slightly in each cmdlet.

      I will put a task on my calendar to work on a version of this document that imports a csv file and post it here.

      • Great! I actually got a Powershell MVP buddy of mine to help me get it close… The only thing I don’t have is a way to set msrtc-groupingid via powershell. Never have been able to find a way to do that. Do you know how that’s done?

  1. Pingback: Tweets that mention Powershell Script to create new user, enable for Exchange, UM and Lync Server « Microsoft UC Made Easy -- Topsy.com

  2. Pingback: Powershell Script to create new user, enable for Exchange, UM and Lync Server « Microsoft UC Made Easy « JC’s Blog-O-Gibberish

  3. Pingback: Script Powershell para criação de novo usuário com Exchange/UM/Lync « Rodrigo Rodrigues .:. www.andersonpatricio.org

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: