Move-Mailbox - works fine in EMS but not with Task Scheduler -confirm parameter
I wanted to test moving the mailbox of a single user after work hours with Task Scheduler (based on a Transcender test prep question)This is the command:Get-Mailbox -identity "jviger" | Move-Mailbox -TargetDatabase "MS01\First Storage Group\Mailbox Database" -confirm $noThis is what happens when I attempt to run it (even manually) in Task Scheduler:[PS] C:\Scripts>.\MoveViger.ps1
Move-Mailbox : Cannot bind argument to parameter 'Identity' because it is null.
At C:\Scripts\MoveViger.ps1:1 char:46
+ Get-Mailbox -identity "jviger" | Move-Mailbox <<<< -TargetDatabase "MS01\First Storage Group\Mailbox Database" -confirm $no
Now, here, I remove the -confirm $no parameter and run thescript directly at the command line in EMS:
[PS] C:\Scripts>.\MoveViger.ps1
Confirm
Are you sure you want to perform this action?
Moving mailbox: Jacques Viger (jviger@acme.org) to database: MS01\First Storage Group\Mailbox Database. The operation can
take a long time and the mailbox will be inaccessible until the move is completed.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
Identity : acme.loc/Users/Jacques Viger
TargetDatabase : MSERV01\First Storage Group\Mailbox DatabaseNote: yes, it works, verified both in the EMC and EMS (Get-Mailbox).The -identity parameter does not seem to be a problem here.Of course, you cannot confirm the operation after hours - unless there is a way to script that.Can anyone see what's not working here?
November 16th, 2009 4:44pm
See how Amithas done this with the help of power shell and scheduler http://exchangeshare.wordpress.com/2008/12/08/how-to-schedule-powershell-script-for-an-exchange-task/See the comments from John and Amit on this post http://social.technet.microsoft.com/Forums/en-US/exchangesvradmin/thread/d5a9ba95-813a-4f97-af1e-0430ae4a382dRaj
Free Windows Admin Tool Kit Click here and download it now
November 16th, 2009 4:54pm
On Mon, 16-Nov-09 13:44:50 GMT, Le Pivert wrote:>I wanted to test moving the mailbox of a single user after work hours with Task Scheduler (based on a Transcender test prep question)This is the command:Get-Mailbox -identity "jviger" | Move-Mailbox -TargetDatabase "MS01\First Storage Group\Mailbox Database" -confirm $noThis is what happens when I attempt to run it (even manually) in Task Scheduler:[PS] C:\Scripts>.\MoveViger.ps1 >>Move-Mailbox : Cannot bind argument to parameter 'Identity' because it is null. >ipts\MoveViger.ps1:1 char:46 >>+ Get-Mailbox -identity "jviger" | Move-Mailbox <<<< -TargetDatabase "MS01\First Storage Group\Mailbox Database" -confirm $no >> >>Now, here, I remove the -confirm $no parameter and run the script directly at the command line in EMS: Try "-confirm:$false" unless you've defined a variable named "$no"someplace else.---Rich MatheisenMCSE+I, Exchange MVP---
Rich Matheisen
MCSE+I, Exchange MVP
November 16th, 2009 5:36pm