12/19/11

Creating some test mailboxes in Exchange 2010 SP1

[PS] C:\Windows\system32>$password = Read-Host -AsSecureString
********

[PS] C:\Windows\system32>for ($i = 1; $i -lt 11; $i++){$name = "MyOrg Test" +
$i; $lastname = "Test " + $i; $userp = $name + "@mydomain.com"; New-Mailbox -Nam
e $name -database "TempDB" -password $password -firstname "MyOrg" -lastname $
lastname -UserPrincipalName $userp}


A simple for loop used to create unquie names for test accounts to use during pre-production testing of the system.

I noticed that this creates the SAM name with spaces so using this .PS1 you can remove spaces from the SAM account name of a mailbox:


Function Remove-Spaces {
param($target)

begin {
filter Do-RemoveSpaces { $_ -replace " ", "" }
}

process { if($_) { $_ Do-RemoveSpaces } }

end { if($target) {$target Do-RemoveSpaces} }
}

for ($i = 1; $i -lt 11; $i++){

$mbx = "MyOrg*" + $i

$samtemp = Get-Mailbox where {$_.name -like $mbx}
$samtempname = $samtemp.SamAccountName

$samtempname = remove-spaces $samtempname

set-mailbox -identity $samtemp -samaccountname $samtempname


That is all for now...

No comments: