Deploying SCOM Agent Remotely via SCCM Scripts

Kody 281 Reputation points
2021-08-31T19:59:04.517+00:00

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

msiexec.exe /i "X:\Applications\SCOM_MOMAgent\MOMAgent.msi" /qn USE_SETTINGS_FROM_AD=0 MANAGEMENT_GROUP=POM MANAGEMENT_SERVER_DNS=scom.server.com MANAGEMENT_SERVER_AD_NAME=scom.server.com ACTIONS_USE_COMPUTER_ACCOUNT=1 USE_MANUALLY_SPECIFIED_SETTINGS=1 AcceptEndUserLicenseAgreement=1  
  
Start-Sleep -s 120  
  
$mma = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'  
$mma.AddManagementGroup('POM' , 'scom.server.com' , 5723)  
$workspaceId = "some-random-numeric-alpha-character"  
$workspaceKey = "some-random-numeric-alpha-character"  
$mma.AddCloudWorkspace($workspaceId , $workspaceKey)  
$mma.SetProxyUrl('oms.server.com:8080')  
$mma.ReloadConfiguration()  
  
$mma1 = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'  
$mma1.AddManagementGroup('DROM' , 'scom2.server.com' , 5723)  
$mma1.ReloadConfiguration()  

128006-sccm-softwarelibrary-scripts.png

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

Thanks..

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
    2021-08-31T21:15:04.643+00:00

    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
    2021-09-01T05:05:31.93+00:00

    Hi,

    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
    128070-powershell-msiexec-01.png

    run under local system context
    128109-powershell-msiexec-02.png

    sample script for your reference

    start-transcript -path "\\10.1.1.2\d\alex\debug0901.txt" -append  
      
    #map the drive dynamically, so that it can be accessible under local system context  
    $command = "\\10.1.1.30\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', 'MANAGEMENT_SERVER_DNS=om16.sc.com', 'MANAGEMENT_SERVER_AD_NAME=om16.sc.com', 'ACTIONS_USE_COMPUTER_ACCOUNT=1', 'USE_MANUALLY_SPECIFIED_SETTINGS=1', 'AcceptEndUserLicenseAgreement=1'  
      
       
    $p = Start-Process 'msiexec.exe' -ArgumentList $params -NoNewWindow -Wait -PassThru  
    $p.ExitCode  
      
    #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' , 'om16.sc.com' , 5723)  
       $mma1.ReloadConfiguration()  
    }  
       
    stop-transcript  
    

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


  3. Limitless Technology 39,461 Reputation points
    2021-09-01T12:56:07.637+00:00

    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 "MgmtServer01.Contoso.com"  
    Install-SCOMAgent -DNSHostName "Server01.Contoso.com" -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
    2021-09-09T17:02:58.907+00:00

    @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. \scom.server.com\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 learn.microsoft.com for the last few days. Anyone is also having issue.


  5. Kody 281 Reputation points
    2021-09-09T17:34:38.907+00:00

    @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 "\10.1.1.2\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.