Link to home
Start Free TrialLog in
Avatar of Dead_Eyes
Dead_EyesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

run a powershell script

Hi don't know if this is possible but running a small domain and I have a powershell script to change a few permissions and delete a file and would like to push it out via group policy. So i created a new policy added the script as a startup script in the computer section and selected the GPO option to run powershell scripts as unrestricted. Problem is the script will still not run from GP (even though it runs fine when I right click it and select run with powershell form the network share). After a little research I have discovered this is because the script is still pausing and asking for permission to run and to overcome this I need to sign the script. I don't have a CA and it seems a little much to but a certificate and go though all that mess just to run a simple script. Is there a way around this issue that does not involve me going round every machine and running the script manually?
Avatar of Dale Harris
Dale Harris
Flag of United States of America image

Our workaround was to run a .bat file that runs a powershell script file with the appropriate executionpolicy.  Example:

@echo off
powershell.exe -windowstyle hidden -executionpolicy unrestricted "Scriptname.ps1"

Try that.
Avatar of Dead_Eyes

ASKER

Thanks for the fast reply, do you know if that would that work for:

@echo off
powershell.exe -windowstyle hidden -executionpolicy unrestricted "\\domian\netlgon\Scriptname.ps1"

and do need to change the exectionpolicy to unrestricted on the GPO or can i just leave it is restricted and the bat file will sort it out? (seems like a good security loophole if you can just use a bat file to change the execution policy lol)
ASKER CERTIFIED SOLUTION
Avatar of Dale Harris
Dale Harris
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial