นี่คือรหัสปัจจุบันของฉัน:
Write-output “ENTER THE FOLLOWING DETAILS - When Creating Multiple New Accounts Go to           EMC hit F5(refresh) and make sure previous new account is listed before proceeding to the       next one”
$DName = Read-Host “User Diplay Name(New User)"
$RUser = Read-Host "Replicate User(Database Grab)"
$RData = ((Get-Mailbox -Identity $RUser).Database).DistinguishedName
$REmailInput = Read-Host “Requester's Name(Notification Email goes to this Person)"
$REmail = ((Get-Mailbox -Identity "$REmailInput").PrimarySmtpAddress).ToString()
Enable-Mailbox -Identity "$DName" -Database "$RData" 
Set-CASMailbox -Identity "$DName" -ActiveSyncEnabled $false -ImapEnabled $false -    PopEnabled $false
Send-MailMessage -From "John Doe <John.Doe@xyz.com>" -To $REmail -Subject       "$DName's email account" -Body "$DName's email account has been setup.`n`n`nJohn Doe`nXYZ`nSystems Administrator`nOffice: 123.456.7890`nJohn.Doe@xyz.com" -SmtpServer exchange@xyz.com
รหัสนี้ใช้งานได้อย่างไม่มีที่ติประมาณครึ่งเวลา แต่อีกครึ่งหนึ่งที่ฉันได้รับข้อผิดพลาดนี้กลับมา:
ENTER THE FOLLOWING DETAILS - When Creating Multiple New Accounts Go to EMC hit
F5(refresh) and make sure previous new account is listed before proceeding to
the next one
User Diplay Name(New User): Jane Doe
Replicate User(Database Grab): Julie Doe
Requester's Name(Notification Email goes to this Person): Joanna Doe
Name                      Alias                ServerName       ProhibitSendQuo
                                                            ta
----                      -----                ----------       ---------------
Jane Doe                  JDDAFA               exchange@xyz.com      unlimited
Set-CASMailbox : Jane Doe is not a mailbox user.
At C:\emailclientbasic.ps1:11 char:15
+ Set-CASMailbox <<<<  -Identity "$DName" -ActiveSyncEnabled $false -ImapEnable
d $false -PopEnabled $false
+ CategoryInfo          : NotSpecified: (0:Int32) [Set-CASMailbox], Manage
mentObjectNotFoundException
+ FullyQualifiedErrorId : 292DF1AC,Microsoft.Exchange.Management.Recipient
Tasks.SetCASMailbox
ดังนั้นหากใครสามารถช่วยฉันโยนคำสั่ง wait บางประเภทหลังจากที่สร้างกล่องจดหมายและรอจนกว่ากล่องจดหมายของผู้ใช้จะถูกสร้างขึ้นก่อนที่สคริปต์จะปิดการใช้งาน ActiveSync ฯลฯ มันจะมีประโยชน์จริง ๆ ฉันเชื่อว่าการใช้สวิตช์รอไม่ได้ผล