I saw this and have not tried it. I maybe dealing with a permission on share folder on sccm server.
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()
Any suggestions on how to resolve my issue and which logs to look at?
Thanks..
Microsoft Security | Intune | Configuration Manager | Application
Microsoft Security | Intune | Configuration Manager | Other
7 answers
Sort by: Most helpful
-
-
AlexZhu-MSFT 6,591 Reputation points Moderator
2021-09-13T02:52:04.377+00:00 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
Alex
If the response is helpful, please click "Accept Answer" and upvote it.