Enjoy Sharing

Managing Systems with Windows PowerShell (Part 2)

This is the second part of my blog entry on PowerShell
Creating Multiple Users & Mailbox in Exchange 2007
$password = ConvertTo-SecureString "P@ssw0rd" -asplaintext -force
$strDatabase = "Mailbox Database"
$strOU = "myTestOU"
$strDomain = "Nwtraders.msft"
$strFname = "My"
$strLname = "TestUser“
for($i=0;$i -le 10;$i++)
New-Mailbox -Alias $strFname$strLname$i  -Database $strDatabase `
-Name $strFname$strLname$i -OrganizationalUnit $strOU -FirstName `
$strFname -LastName $strLname -DisplayName $strFname$strLname$i `
-UserPrincipalName $strFname$strLname$i"@"$strDomain `
-password $password
  • First create a variable to tell the cmdlet on which database it is to create the new mail-enabled user.
  • Then create a variable to hold the name of the OU where this user will be created.
  • Then a string for the domain portion of the user name.
  • Create a variable to hold the user’s firstname.
  • And also one to hold the user’s lastname.
  • The for loop starts which executes the mailbox creation cmdlet.
In order to assign a password to every mail-enabled user, I cannot simply use $strPwd = "P@ssw0rd" which seems a logical thing to do but does not work because a password is considered a secured string, therefore the need to convert to plaintext.
Something that I’ve probably not yet mentioned here is the discovery commands that you can use in PowerShell to get you started learning of what cmdlets are available. Here are some of the commands you can use right away to begin exploring Windows PowerShell.
Get-Command – Gives you all the cmdlets available
Get-Help – Displays the help for PowerShell or a particular cmdlet and the usage of the cmdlets
In summary, you might not be able to learn every cmdlet there are out there (nobody expects you to) but this is how you can get started on it; so as I’ve said before in the session…..Try It, Deploy It, Use It, Share It!

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 )

Google+ photo

You are commenting using your Google+ 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