dpmConfigKeyPath = "SOFTWARE\Microsoft\Microsoft Data Protection Manager\Configuration"
DPMScomGroupName = "DPMScom"
'Reading Registry
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set oArgs = WScript.Arguments
ManagementServersString = oArgs(0)
call oAPI.LogScriptEvent("AddManagementServer", 130, 4, "Adding management server:" & ManagementServersString)
'Split the management server machine names
MachinesArray = Split(ManagementServersString, ";")
for each MachineName in MachinesArray
'Adding To DPMScom Group Variables
MachineName = Trim(MachineName)
'Seperating Machine name and domain name
DotPosition = InStr (MachineName, ".")
DomainName = Mid (MachineName, DotPosition+1)
DotPosition2 = InStr (DomainName, ".")
simpleDomainName = Mid (DomainName, 1, DotPosition2 - 1)
ManagementServerName = Mid (MachineName, 1, DotPosition-1) & "$"
call oAPI.LogScriptEvent("AddManagementServer", 130, 4, "SCOM Machine Name:" & DomainName &"\" & ManagementServerName)
Set net = WScript.CreateObject("WScript.Network")
local = net.ComputerName
'Read Machine Name
Set WshShell = WScript.CreateObject("WScript.Shell")
DPMMachineName = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
DPMScomGroupNameDCMachineName = "DPMScom$" & DPMMachineName
'Adding SCOMServer to DPMSCOM Group for non-dc machine
set group = GetObject("WinNT://"& local &"/" & DPMScomGroupName)
group.Add "WinNT://"& DomainName &"/"& ManagementServerName &""
'Adding SCOMServer to DPMSCOM Group for dc machine
set group = GetObject("WinNT://"& local &"/" & DPMScomGroupNameDCMachineName)
group.Add "WinNT://"& DomainName &"/"& ManagementServerName &""
'Adding registry for the scomserver to indicate when discovery happened subKeyName = "domain\serverName$" value = "Just Discovered"
valueTemp = "Just Discovered"
subKeyValue = simpleDomainName &"\"& ManagementServerName
oReg.SetStringValue HKEY_LOCAL_MACHINE, dpmConfigKeyPath, subKeyValue, valueTemp
next