Deploying SCOM Agent Remotely via SCCM Scripts

Kody 281 Reputation points

I'm trying to install SCOM client through a PowerShell script and register it through OMS server. The script works when ran locally. But, it doesn't when configured via SCCM Software Library \ Scripts (Slightly modified drive letter). When Deploying to a selected client (Assents and Compliance\Devices) by right click, Run Script and selecting the PowerShell script. It goes through the normal process and returns with the Script Status Monitor Exit Code 0, see screenshot. But, remotely logging into the client, I don't see the Microsoft Monitoring Agent on the Control Panel and I don't see it on the SCOM server.

I'm not sure which log to look at on both the sccm server (C:\Program Files\Microsoft Configuration Manager\Logs) and on the client end (C:\Windows\CCM\Logs).

Here's my script

Start-Sleep -s 120  
$mma = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'  
$mma.AddManagementGroup('POM' , '' , 5723)  
$workspaceId = "some-random-numeric-alpha-character"  
$workspaceKey = "some-random-numeric-alpha-character"  
$mma.AddCloudWorkspace($workspaceId , $workspaceKey)  
$mma1 = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'  
$mma1.AddManagementGroup('DROM' , '' , 5723)  


Any suggestions on how to resolve my issue and which logs to look at?


Microsoft Configuration Manager Application
Microsoft Configuration Manager Application
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Application: A computer program designed to carry out a specific task other than one relating to the operation of the computer itself, typically to be used by end users.
464 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Jason Sandys 31,181 Reputation points Microsoft Employee

    What's the X drive and how would the local system account on a managed client have an X drive?

    Why aren't you using an Application for this so that the content can be delivered as well?

    1 person found this answer helpful.
    0 comments No comments

  2. AlexZhu-MSFT 5,551 Reputation points Microsoft Vendor


    It seems the msiexec didn't run successfully and the most possible reason is that the path is not recognized. As Jason mentioned above, when admistering from ConfigMgr, the account is SYSTEM. By defult, powershll call the command but not care about whether it succeeds. We need to confirm that the SCOM agent installation is successful before applying any configuration.

    To test this, I've modified the script slightly, test with local system and the MMA appears in the control panel.

    drive x: does not exit, however, it shows true as the result for powershell

    run under local system context

    sample script for your reference

    start-transcript -path "\\\d\alex\debug0901.txt" -append  
    #map the drive dynamically, so that it can be accessible under local system context  
    $command = "\\\c$\System Center Operations Manager 2019\agent\AMD64"  
    $command = "cmd /c net use x: "+ '"' + $command + '"' + " /user:<domain\user> <password>"  
    invoke-expression $command  
    $params = '/i', "X:\MOMAgent.msi", '/qn', 'USE_SETTINGS_FROM_AD=0', 'MANAGEMENT_GROUP=test01', '', '', 'ACTIONS_USE_COMPUTER_ACCOUNT=1', 'USE_MANUALLY_SPECIFIED_SETTINGS=1', 'AcceptEndUserLicenseAgreement=1'  
    $p = Start-Process 'msiexec.exe' -ArgumentList $params -NoNewWindow -Wait -PassThru  
    #unmap the drive  
    $command = "cmd /c net use x: /delete"  
    invoke-expression $command  
    #Start-Sleep -s 12  
    #if the installation succeeds, contine the configuration      
    if ($p.exitcode -eq 0)  
       $mma1 = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'  
       $mma1.AddManagementGroup('test01' , '' , 5723)  

    If the response is helpful, please click "Accept Answer" and upvote it.

  3. Limitless Technology 39,461 Reputation points

    Hi @Kody

    I would suggest you to Install an agent on a server by using the action account credentials and see if that helps .
    A sample like this

    $InstallAccount = Get-Credential  
    $PrimaryMgmtServer = Get-SCOMManagementServer -ComputerName ""  
    Install-SCOMAgent -DNSHostName "" -PrimaryManagementServer $PrimaryMgmtServer -ActionAccount $InstallAccount  

    Hope this Answers all your queries , if not please do repost back .
    If an Answer is helpful, please click "Accept Answer" and upvote it : )

    0 comments No comments

  4. Kody 281 Reputation points

    @Jason Sandys

    The x: drive is a temp virtual drive that I created for this test. I've tried using a FQDN name.
    (e.g. \\Applications\SCOM_MOMAgent\MOMAgent.msi)

    When you say "Why aren't you using an Application for this so that the content can be delivered as well?" are you referring to when right click on the object and select Install Application?

    I'd like to be able to do that. But, I'm unsure how to set that up.

    Sorry for the the late response. I can't seem to response or upload screenshots to the forum at for the last few days. Anyone is also having issue.

  5. Kody 281 Reputation points

    @AlexZhu-MSFT ,

    I can't seem to get the script to run via sccm script installer. No script debugging logs (like your example: start-transcript -path "\\d\alex\debug0901.txt") going into the network share on the sccm share folder. I'm wondering if it's a permission thing. Is there a log that I can look that I can look at within the sccm logs that's dedicated to script installer like ccm.log when deploying sccm clients.