How to task schedule an Exchange Powershell script on non-Exchange computer

The other day I had to write a Powershell script that utilised some Exchange Powershell cmdlets. This script had to run as a scheduled task on a non-exchange server that did not have the Exchange Management tools installed, nor was this an option.

To do this I knew I had to import the Exchange cmdlets to the remote computer and then run the script.

Here is the command line that I used in task scheduler to achieve my goal:

 

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YourexchangeServer.yourDomain.com/PowerShell/ -Authentication Kerberos ; Import-PSSession $s; &'c:\Path\to\script\ExchangeScript.ps1'"

Be the first to comment

Leave a Reply