question

Kody-2675 avatar image
0 Votes"
Kody-2675 asked AlexZhu-MSFT edited

Deploying SCOM Agent Remotely via SCCM Scripts

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..

mem-cm-generalmem-cm-application
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Jason-MSFT avatar image
0 Votes"
Jason-MSFT answered

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?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlexZhu-MSFT avatar image
0 Votes"
AlexZhu-MSFT answered AlexZhu-MSFT commented

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.




· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

It seems there is no update for a couple of days. May we know the current status of the problem? Or is there any other assistance we can provide?

Regards,

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

0 Votes 0 ·
LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hi @Kody-2675

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 : )

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Kody-2675 avatar image
0 Votes"
Kody-2675 answered Jason-MSFT commented

@Jason-MSFT

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 docs.microsoft.com for the last few days. Anyone is also having issue.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

are you referring to when right click on the object and select Install Application?

No. The entire model of ConfigMgr app deployment includes delivering the source files to the targeted clients so that they don't need to be accessed remotely as accessing source files remotely is fraught with challenges and issues. Thus, when you create an application, you specify a location for that application's source files that ConfigMgr grabs for this express purpose.

0 Votes 0 ·
Kody-2675 avatar image
0 Votes"
Kody-2675 answered AlexZhu-MSFT edited

@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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

The script is just a sample to illustrate how it works. Line 1 and line 29 is optional and we we remove it. the key is line 11 and line 12 (to get the exitcode before proceeding the configuration).

In a word, the entire script should be modified to suit your actual environment.

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

0 Votes 0 ·
Kody-2675 avatar image
0 Votes"
Kody-2675 answered

@LimitlessTechnology-2700

I saw this and have not tried it. I maybe dealing with a permission on share folder on sccm server.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlexZhu-MSFT avatar image
0 Votes"
AlexZhu-MSFT answered

Hi,

How's everything going? Have we figured out this problem? We can use psexec to simulate SYSTEM account to run the script. If testing is OK, then we can deploy it.

Here's the test scipt (some sensitive information is filtered)

 #map the drive dynamically, so that it can be accessible under local system context
 Write-Host "mapping the drive..." -NoNewline
    
 $command = "\\10.1.1.30\c$\System Center Operations Manager 2019\agent\AMD64"
 $command = "cmd /c net use t: "+ '"' + $command + '"' + " /user:<domain\username> <password>"
 invoke-expression $command
    
 set-location t:
    
 $map_drive_result = $?
    
 if ($map_drive_result)
 {
     write-host "succeed"
 }
 else
 {
     write-host "failed"
     exit
 }
    
     
 $params = '/i', "t:\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'
    
 write-host "start the agent installation..."
     
 $p = Start-Process 'msiexec.exe' -ArgumentList $params -NoNewWindow -Wait -PassThru
 $p.ExitCode
    
 if ($p.exitcode -eq 0)
 {
     write-host "the scom agent installation was successful!"
 }
 else
 {
     $error_info = "the scom agent installaion failed with error code: " + $p.exitcoce.tostring()
     write-host $error_info 
 }
    
 #unmap the drive
 $command = "cmd /c net use t: /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('test02' , 'om19.sc.com' , 5723)
     if ($? -eq 0)
     {
         write-host "a new (but inactive) management group was added!"
     }
     $mma1.ReloadConfiguration()
 }



And here's the test result

131350-sccm-scom-agent-install-02.png

131349-sccm-scom-agent-install.png

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



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.