Ok, so Rob's script will sleep for 2 seconds at a time until the Get-Mailbox command is successful, right? What does the $MBX reference? Do I need something in the .csv called that?
From: Rob Campbell [mailto:rob_campb...@centraltechnology.net] Sent: Friday, December 21, 2012 5:24 AM To: Heaton, Joseph@DFG; MS-Exchange Admin Issues Subject: RE: Add a pause in a script? Alternatively: $mbxs = Import-Csv \Users.csv Foreach ($MBX in $mbxs){ Enable-Mailbox -Identity $MBX.LoginName -domainController DC1 } 'Waiting for mailbox creation to complete' Do {Sleep 2} Until (Get-Mailbox $mbxs[-1].loginname) Foreach ($MBX in $mbxs){ Write-Output "Creating inbox rule for $($MBX_.LoginName) to redirect to $($MBX.EmailAddress)" New-InboxRule -name "Redirect Mail" -Mailbox $MBX.LoginName -redirectto $MBX.EmailAddress -domainController DC1 } From: Michael B. Smith [mailto:mich...@smithcons.com] Sent: Friday, December 21, 2012 6:13 AM To: MS-Exchange Admin Issues Subject: RE: Add a pause in a script? If you specify the domainController on each command, it will probably work immediately. For example, assume the local DC is named DC1. I also illustrated a couple of other useful techniques. :) Import-Csv .\Users.csv | Foreach-Object{ Enable-Mailbox -Identity $_.LoginName -domainController DC1 Sleep 5 ### delay for 5 seconds Write-Output "Creating inbox rule for $($_.LoginName) to redirect to $($_.EmailAddress)" New-InboxRule -name "Redirect Mail" -Mailbox $_.LoginName -redirectto $_.EmailAddress -domainController DC1 } From: Heaton, Joseph@DFG [mailto:jhea...@dfg.ca.gov] Sent: Friday, December 21, 2012 12:35 AM To: MS-Exchange Admin Issues Subject: Add a pause in a script? I want to create a bunch of mailboxes, then add a redirect rule to them. I have my .csv file with names (LoginName) and addresses to forward to (EmailAddress). Here is the script: Import-Csv .\Users.csv | Foreach-Object{ Enable-Mailbox -Identity $_.LoginName New-InboxRule -name "Redirect Mail" -Mailbox $_.LoginName -redirectto $_.EmailAddress } The mailboxes are created fine, but then I get an error when it tries to create the inbox rule, saying the mailbox doesn't exist. If I wait 5-10 minutes, comment out the Enable-Mailbox line, and run the script again, it works fine, and creates the inbox rule. The one thing it doesn't do at that point is tell me what mailbox it's creating the inbox rule for. Is there a way to have it echo the mailbox, then create the inbox rule, so I can go back and verify that they were all done? As always, thanks for any and all help on this. Joe Heaton --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> with the body: unsubscribe exchangelist --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> with the body: unsubscribe exchangelist ************************************************************************************************** Note: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. ************************************************************************************************** --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> with the body: unsubscribe exchangelist --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to listmana...@lyris.sunbeltsoftware.com with the body: unsubscribe exchangelist