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?
Microsoft ApplicationsScripting LanguagesPowershell

Avatar of undefined
Last Comment
WPincusIT

8/22/2022 - Mon
Raheman M. Abdul

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.
slavs

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

To add to Rahemans idea, are you impersonating a user?
Raheman M. Abdul

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
WPincusIT

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
marek1712

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
WPincusIT

It was a GPO that had the execution policy set to only -Allsigned which was overriding the local setting