osagarana
asked on
Run Exchange Powershell cmdlt from Task Scheduler does not work
Environment:
Exchange 2010 SP2
MS Windows Server 2008 R2
Hi Experts,
I am having a hard time to run my Exchange command from task scheduler and now I am running out of ideas.
The command is simple: Get-ClientAccessServer | Update-FileDistributionSer ver -Type OAB
Everything runs perfectly when I run this command from Exchange Shell.
So I tried to set a Task Scheduler to run this command.
Program/script: powershell.exe
Add arguments (optional): -version 2.0 -NonInteractive -WindowStyle Hidden -executionpolicy bypass -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExcha nge.ps1'; Connect-ExchangeServer -auto; &{Get-ClientAccessServer | Update-FileDistributionSer vice -Type OAB}"
It does not work. I already tried everything. I using the administrator user to create this task. I suspect it can be lack of permissions from task scheduler. I do not know.
Any ideas?
Exchange 2010 SP2
MS Windows Server 2008 R2
Hi Experts,
I am having a hard time to run my Exchange command from task scheduler and now I am running out of ideas.
The command is simple: Get-ClientAccessServer | Update-FileDistributionSer
Everything runs perfectly when I run this command from Exchange Shell.
So I tried to set a Task Scheduler to run this command.
Program/script: powershell.exe
Add arguments (optional): -version 2.0 -NonInteractive -WindowStyle Hidden -executionpolicy bypass -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExcha
It does not work. I already tried everything. I using the administrator user to create this task. I suspect it can be lack of permissions from task scheduler. I do not know.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
First of all try changing it with the CMDLet Set-ExecutionPolicy unrestricted and lets check if it returns the same error
You can configure the parameter back with Set-ExecutionPolicy RemoteSigned
You can configure the parameter back with Set-ExecutionPolicy RemoteSigned
ASKER
It started to work. But I tested on my lab. :-)
I need to test on the production which is set to RemoteSigned.
Is there a way to bypass this execution policy?
I need to test on the production which is set to RemoteSigned.
Is there a way to bypass this execution policy?
You can sign your script, at this website they explain how can you make it: http://www.mikepfeiffer.net/2010/02/obtaining-a-code-signing-certificate-and-signing-powershell-scripts/
Another option is just configure your execution policy to unrestricted like you did. But it is less secure as far as the system won't validate any kind of script sign before executing
Another option is just configure your execution policy to unrestricted like you did. But it is less secure as far as the system won't validate any kind of script sign before executing
ASKER
I tested with this argument and it worked:
-version 2.0 -NonInteractive -WindowStyle Hidden -executionpolicy unrestricted -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExcha nge.ps1'; Connect-ExchangeServer -auto; &{Get-ClientAccessServer | Update-FileDistributionSer vice -Type OAB}"
-version 2.0 -NonInteractive -WindowStyle Hidden -executionpolicy unrestricted -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExcha
ASKER
[PS] C:\Windows\system32>Get-Ex
RemoteSigned