/build/static/layout/Breadcrumb_cap_w.png

Problem with Running powershell script thru SCCM

Hello Folks,

I have been having a problem with running a powershell script thru sccm.
The script works fine if I run as admin.
but that problem with sccm. I can't able to execute the script thru SCCM although check the run with admin. privileges.

I pretty sure about powershell command line :
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file "x.ps1"

(or ) powershell.exe -Execuationpolicy Bypass -command ".\file.ps1"

Tried to run the ps with bat file - No luck

Please share your thoughts.

Thanks,
Alex

0 Comments   [ + ] Show comments

Answers (2)

Posted by: anonymous_9363 6 years ago
Red Belt
1
There's your problem. The System account had no network access. Copy the file locally and execute it from there or have the script run in user context. If course, the latter might fail if the script is doing anything that requires elevated privileges.
Posted by: anonymous_9363 6 years ago
Red Belt
0
You need to specify the full path to the script.. In the 2 forms you show, PS will be looking for it in the current directory, whatever that might be. Make sure it's in a known location. On my builds, I like to create 'C:\Users\Public\Scripts' and throw stuff in there. Thus:

powershell.exe -ExecutionPolicy Bypass -command "C:\Users\Public\Scripts\file.ps1"

Comments:
  • my script stays on network shared location. \\x\apps\gc\script\x.ps1. Is this best practice to do that? - srisidhu558 6 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ