Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

powershell command exchange 2010

I am mass moving a bunch of users and wondering if there is a way I can tweak this command to email me once the job finishes moving the mailboxes on exchange.



Open in new window

Import-CSV "c:\temp\massmoves3.csv" | foreach {New-MoveRequest -Identity $_.displayname -Target
Database $_.database}

Open in new window

0
techdrive
Asked:
techdrive
1 Solution
 
QlemoC++ DeveloperCommented:
Sending the mail isn't difficult (pointer: Send-MailMessage), but waiting for the asynchronous move requests to finish is. We have to wait until there is no further task queued or in progress.
Import-CSV "c:\temp\massmoves3.csv" | foreach {
  New-MoveRequest -Identity $_.displayname -TargetDatabase $_.database
}
while ((Get-MoveRequest -MoveStatus Queued) -or (Get-MoveRequest -MoveStatus InProgress))
{
   start-sleep 15  # seconds
}
Send-MailMessage -SmtpServer mx.MyCompany.Com -From Me@MyCompany.Com -To Me@Mycompany.Com -Subject 'Finished Mailbox Move Requests'

Open in new window

0
 
techdriveAuthor Commented:
Qlemo you are a genius thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now