Stop a Exchange Management Shell Script

ams_group
ams_group used Ask the Experts™
on
Hi,

I'm wanting to test the following script which exports all mailboxes in a database to PST files. We are use Exchange 2010 SP1

foreach ($i in (Get-Mailbox -ResultSize Unlimited|Where {$_.Database -eq "Database Name"})) { New-MailboxExportRequest -Mailbox $i -FilePath "\\ServerName\pstexport_ctp \$($i.Alias).pst" }

Once the script starts processing mailboxes, how can it be stopped? Will simply closing the command Window do the trick? I only want it to run for long enough to ensure that it is working.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
While the management shell window is open, hold down the <CTRL> key and press the "c" key. (i.e. CTRL+C). That will interrupt the processing of the script.
I agree with neilpage99 but you can also just shut the machine down normally. Database copies won't go anywhere.
Technical Development Lead
Commented:
Dont forget that stopping the script will NOT stop the processing of your move-requests. That script will not wait after each one and will process a LOT of mailboxes in a very short time.

Why do you want to STOP the script?

You would be far better off doing....

foreach ($i in (Get-Mailbox -ResultSize Unlimited|Where {$_.Database -eq "Database Name"})) { New-MailboxExportRequest -Mailbox $i -FilePath "\\ServerName\pstexport_ctp \$($i.Alias).pst" -whatif }

That will tell you WHAT it would be doing and if there would be any errors.  OR Single step through it one line at a time in PowerGUI (Free powershell IDE) and just run one or two mailboxes if you must.

Author

Commented:
Thanks, -whatif worked a treat.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial