/bundles/itninjaweb/img/Breadcrumb_cap_w.png
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   [ - ] Hide Comments

Comments

Please log in to comment

Community Chosen Answer


Answers

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.
Answered 01/13/2018 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity

Answers

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"
Answered 01/12/2018 by: VBScab
Red Belt

  • my script stays on network shared location. \\x\apps\gc\script\x.ps1. Is this best practice to do that?
Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share