Here's a quick example for creating a scheduled task to run a .ps1 script in exchange powershell, it is not as simple as you might think…
The parameters to be passed are:
Program or script: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
Arguments: -NonInteractive -WindowStyle Hidden -command “. ‘C:Program FilesMicrosoftExchange ServerV15binRemoteExchange.ps1’; Connect-ExchangeServer -auto; c:ScriptsExchangescript_name.ps1”
If you have an easier method post it in the comments, Thank you!!
This is german, but it’s easily translatable:
https://blog.orbit.de/2017/09/12/powershell-skripte-mit-unc-pfaden-in-der-aufgabenplanung/
Here you will see *four* different ways to schedule a task with local paths without parameters, with parameters and the same with UNC paths. Might be helpful!
Thanks for the info Tobias! 🙂