Thursday, July 12, 2012

[OpsMgr 2012] Installing OpsMgr 2012 Agents with CU1 with a command Line

The script provided by Joe Thompson allow you to install the SCOM 2012 Agent and the CU1 with a single command line :
msiexec /i MOMAgent.msi /qn /l*v %TEMP%\install.log PATCH="C:\MyPath\KB2674695-amd64-Agent.msp USE_SETTINGS_FROM_AD=0 USE_MANUALLY_SPECIFIED_SETTINGS=1 MANAGEMENT_GROUP=MYNEWMG MANAGEMENT_SERVER=SCOM2012.MYDomain.net SECURE_PORT=5723 ACTIONS_USE_COMPUTER_ACCOUNT=1"
  
 Be sure parameter are correct to launch the command line.
Here is the script :
  1. ' OMINSTALL.VBS
  2. ' Version 1 (2012-06-27)
  3. ' Joe Thompson, EP Energy LLC
  4. ' OM 2012 vbs installer with CU1 agent patch and MGMT Group reconfig
  5.   
  6. Option Explicit
  7.   
  8. Dim sho, sCurPath, oReg, strKeyPath, strValueName, strComputer, strCmd, strVal, objMSConfig, intSleep, intRet
  9.   
  10. Set sho = Wscript.CreateObject("Wscript.Shell")
  11. sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
  12. strComputer = "."
  13. intSleep = 15000
  14. wscript.echo "Running installer..."
  15. strCmd = "msiexec /i MOMAgent.msi /qn /l*v %TEMP%\install.log PATCH=" & sCurPath & "\KB2674695-amd64-Agent.msp USE_SETTINGS_FROM_AD=0 USE_MANUALLY_SPECIFIED_SETTINGS=1 MANAGEMENT_GROUP=MYNEWMG MANAGEMENT_SERVER=SCOM2012.MYDomain.net SECURE_PORT=5723 ACTIONS_USE_COMPUTER_ACCOUNT=1"
  16. wscript.echo strCmd
  17. intRet = sho.run(strCmd,0,True)
  18.   
  19. ' Let things calm down
  20. wscript.echo "Sleeping..."
  21. WSCript.Sleep intSleep
  22.   
  23. ' Check registry for OM Mgmt Group info
  24. If intRet <> 0 Then
  25.                 wscript.Echo "Install error occurred.... "
  26.                 wscript.quit(intRet)
  27. Else
  28.                 On Error Resume Next
  29.                 wscript.echo "Checking registry for OM 2012 EPE Mgmt Group info..."
  30.                 strVal = sho.RegRead("HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups\MYNEWMG\")
  31.                 If Err <> 0 Then    ' regkey doesn't exist
  32.                                 wscript.echo "Didn't find OM 2012 EPE Mgmt Group info, setting config..."
  33.                                 Set objMSConfig = CreateObject("AgentConfigManager.MgmtSvcCfg")
  34.                                 'Add a management group
  35.                                 Call objMSConfig.AddManagementGroup ("MYNEWMG", "SCOM2012.MYDomain.net",5723)
  36.                                 WSCript.Sleep intSleep
  37.                                 wscript.echo "Reloading agent Mgmt Group configuration..."
  38.                                 Call objMSConfig.ReloadConfiguration
  39.                 End If
  40. End If
  41.   
  42. wscript.quit(intRet)


This posting is provided "AS IS" with no warranties.

No comments:

Post a Comment