zito2000
asked on
Save Exchange PowerShell Command
Environment: Exchange 2013
Hi All,
I am trying to accomplish what I think it pretty simple.
I have an Exchange Management Shell command (Move-ActiveMailboxDatabas e command to move my active database server) and I want to save it to my desktop. How do I go about doing it?
I want to be able to double-click the script and it execute the Powershell script.
Thank you in advance!
Hi All,
I am trying to accomplish what I think it pretty simple.
I have an Exchange Management Shell command (Move-ActiveMailboxDatabas
I want to be able to double-click the script and it execute the Powershell script.
Thank you in advance!
Copy/paste in notepad first and then save it as .ps1.
ASKER
I tried the first method, and it failed. I'm thinking because it's an Exchange Management Shell command, and not a Powershell command.
"Move-ActiveMailboxDatabas e : the term 'Move-ActiveMailboxDatabas e" is not recognized as the name of a cmdlet"
"Move-ActiveMailboxDatabas
You need to call the Exchange snap-in in your command.
I don't think is going to work from workstation.
If you'll save as .ps1 file and double click on it it will run Windows PowerShell on your computer.
To make this command work on Exchange you need to modify link to run Exchange PowerSchell from Exchange server or install Exchange Tools on your computer
This is link where Exchange powerschell is installed
C:\Windows\System32\Window sPowerShel l\v1.0\pow ershell.ex e -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExcha nge.ps1'; Connect-ExchangeServer -auto -ClientApplication:Managem entShell "
If you do have Exchange Tools installed on your PC then you can run it by replacing RemoteExchange.ps1 with your file
If you'll save as .ps1 file and double click on it it will run Windows PowerShell on your computer.
To make this command work on Exchange you need to modify link to run Exchange PowerSchell from Exchange server or install Exchange Tools on your computer
This is link where Exchange powerschell is installed
C:\Windows\System32\Window
If you do have Exchange Tools installed on your PC then you can run it by replacing RemoteExchange.ps1 with your file
ASKER
Amit - How do I call the Exchange Snap In?
Tom - I plan on running this directly on the Exchange server, which obviously has Exchange Tools on it
Tom - I plan on running this directly on the Exchange server, which obviously has Exchange Tools on it
Follow the attached document for powershell remoting into exchange :- https://technet.microsoft.com/en-us/library/dd335083(v=exchg.160).aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try out Tom advise above.
ASKER
Thanks everyone. I'm keeping this question active because I still need to test it. Going to get to it today or tomorrow.
Thanks again for your help, all.
Thanks again for your help, all.
ASKER
Tom/Qlemo,
Thank you for your help.
I used Qlemo's revision to Tom's original post and it worked like a charm! Thank you both for the help with this!!
Have a great day!
Thank you for your help.
I used Qlemo's revision to Tom's original post and it worked like a charm! Thank you both for the help with this!!
Have a great day!
You can right click the file than and click run with powershell or you can put into the batch file and run the batch by double clicking.
Below link should help in creating the batch file: https://www.howtogeek.com/204088/how-to-use-a-batch-file-to-make-powershell-scripts-easier-to-run/