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
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)
Please log in to answer
Posted by:
anonymous_9363
6 years ago
Posted by:
anonymous_9363
6 years ago
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