Link to home
Avatar of WPincusIT
WPincusIT

asked on

Powershell

When I create and run a powershell script on my machine, it runs fine.  When I deploy the script using SCCM, the script fails.  I check a target machine and change the Powershell execution policy to unrestricted but it still fails.  What could be the problem?
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you running the script under the user who have enough rights to access the resources you are using from it?
If you could post the error it will be easy for experts to comment please.
Avatar of slavs
slavs

Have you checked that the target machine allows remoting via Enable-PSRemoting?

To add to Rahemans idea, are you impersonating a user?
compare the versions of powershell on both machines. (some cmdlets wont run on lower version)
As suggested by slavs, run "Enable-psremoting" cmdlet on the the target machine and see if it works.
what happens when you copy the script to target machine and run from locally
Avatar of WPincusIT

ASKER

When I run the script on the target machine locally as  local administrator, it does not run as well.  When I change the execution policy to unrestricted I get an error "Windows Powershell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope"
ASKER CERTIFIED SOLUTION
Avatar of marek1712
marek1712
Flag of Poland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
It was a GPO that had the execution policy set to only -Allsigned which was overriding the local setting