Friday, September 30, 2011

Executing a PowerShell script from the command line

Actually, this should have been easy. I had a PowerShell script that should be started from a batch file inside a Group Policy Object.

However, starting the script failed on several computers, either because the execution policy was no set or because the user had changed the configuration so PowerShell was waiting for user input when started.

This is command I finally used that could overcome all these problems. It has run successfully on any computer so far.

powershell.exe -NonInteractive -ExecutionPolicy Bypass -file "C:\Script\DoIt.ps1"

No comments:

Post a Comment