Link to home
Start Free TrialLog in
Avatar of Orlando Gomez
Orlando GomezFlag for United States of America

asked on

run multiple commands Exchange powershell

I have an Exchange powershell file .ps1 named forwardoff.ps1 which has the following commands. I right click on the .ps1 files and run with powershell but it errors out.  When I run manually thru exchange PowerShell each command one at a time they run successfully. What am I doing wrong.? I need to be able to see the result which is why I added the "press any key to continue"

Set-Mailbox user1 -ForwardingAddress $Null;
Set-Mailbox user2  -ForwardingAddress $Null;
Set-Mailbox user3 -ForwardingAddress $Null;
Set-Mailbox user4 -ForwardingAddress $Null;

Read-Host -Prompt "Press Enter to continue"
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Remove the " ; " from the end of each command. and try again.

Will.
ASKER CERTIFIED SOLUTION
Avatar of Sudeep Sharma
Sudeep Sharma
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial