Getting syntax error with code copied from Microsoft.com
HI - I'm trying to script the create of >500 AD accounts with mailboxes. I found this website: http://technet.microsoft.com/en-us/library/bb310752(EXCHG.80).aspx and am using the code from that page verbatim: Import-CSV "C:\NewUsers.csv" | ForEach-Object -Begin {$Temp = ConvertTo-SecureString "pass@word1" -asPlainText -Force} -Process {New-Mailbox -Name $_.Name -UserPrincipalName "$($_.UserName)@contoso.com" -OrganizationalUnit "contoso.com/Users" -Database "Server01\Mailbox Database" -Password $Temp -ResetPasswordOnNextLogon $true} - except for using my OU, data path, UPN suffix,and Exchange database name. I get this error: ForEach-Object : A positional parameter cannot be found that accepts argument '-'. At C:\users\...\Desktop\tentative.ps1:1 char:67 + Import-CSV "C:\Users\...\Desktop\test.csv" | ForEach-Object <<<< -Begin {$Temp = ConvertTo-SecureString "pass@word1" -asPlainText -force} -Process {New-Mailbox -Name $_.displayName -UserPrincipalName ...the rest of my script goes here... + CategoryInfo : InvalidArgument: (:) [ForEach-Object], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand Any suggestions? Thanks very much!
January 20th, 2011 2:45pm

Never mind - I found my error - an extra "-" Thanks every one!
Free Windows Admin Tool Kit Click here and download it now
January 20th, 2011 2:53pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics