Run Powershell script as administrator in SCCM Package

Jason Steeves 136 Reputation points
2021-09-27T02:00:06.92+00:00

I have a powershell script that is functioning correctly but when I package it into SCCM and run it on my test machines it's failing. This has been tested and if the script is run "as administrator" then it works fine.........if I manually run with normal credentials then that's when it gives me the error. This is failing even if I set the sccm package to run as administrator.

Please advise how I can get this powershell script to "Run As Administrator".

Microsoft Configuration Manager
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Amandayou-MSFT 11,041 Reputation points
    2021-09-27T05:57:19.717+00:00

    Hi @Jason Steeves ,

    When we deploy the package by sccm, it uses the system computer account. To narrow down the problem, we could use PSTools to test if the problem is related with SCCM, which uses system computer account.

    Here is the download link about PSTools:
    https://learn.microsoft.com/en-us/sysinternals/downloads/pstools

    Please run the script using system account, refer to this following screenshot:

    135396-927.png


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Garth 5,801 Reputation points
    2021-09-27T11:39:03.793+00:00

    You need to find out why it is failing. You can do this but adding logging to your script or running it interactively. It could also be an x86 issue too. This blog gives more details. https://www.recastsoftware.com/resources/how-to-access-the-local-system-account/

    0 comments No comments

  3. Jason Steeves 136 Reputation points
    2021-09-27T12:21:02.317+00:00

    I created the sccm package to run the cmd as the local system account and when I run the powershell script I'm getting the error below. Any idea why this error is happening?

    135544-image.png

    0 comments No comments

  4. Garth Jones 1,656 Reputation points
    2021-09-27T12:36:47.363+00:00

    No idea, If I had to guess it is an x86 issue based on what you have said. But at least you have something to troubleshoot.

    0 comments No comments

  5. Jason Steeves 136 Reputation points
    2021-09-27T14:21:00.707+00:00

    what I'm doing is trying to add a SCOM server into the SCOM client and this is working via powershell and vbscript if I run the scripts with "Run As Administrator" privileges.............but as soon as I launch this from a regular command prompt then it fails.

    0 comments No comments