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 Security | Intune | Configuration Manager | Other
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Amandayou-MSFT 11,166 Reputation points
    2021-10-04T08:24:27.57+00:00

    Hi @Jason Steeves

    Here is the script about deploying SCOM Agent Remotely:
    $mma1 = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'
    $mma1.AddManagementGroup('test02' , 'om19.sc.com' , 5723)
    if ($? -eq 0)
    {
    write-host "a new (but inactive) management group was added!"
    }
    $mma1.ReloadConfiguration()

    For more details, we could refer to this following post, kindly focus on Alex's last reply.
    https://learn.microsoft.com/en-us/answers/questions/534916/deploying-scom-agent-remotely-via-sccm-scripts.html


    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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.