' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' Declare and Init some objects
Option Explicit
Dim oAPI, oDiscoveryData, oInst, oArgs, oReg ' Use global variables to speedup the script!
Dim SourceID, ManagedEntityId, TargetComputer, ComputerName, IP
Dim strComputer, ver, bytecode, BEwin, path, fullpath,release, major, minor
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "localhost"
BEwin = "SOFTWARE\Symantec\Backup Exec For Windows\Backup Exec\"
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' Check for the number of arguments
Set oArgs = WScript.Arguments
if oArgs.Count < 5 Then
Call oAPI.LogScriptEvent("Server_Discovery.vbs",1010,1, "Insuficient number of parameters. Script was aborted.")
Wscript.Quit -1
End If
Call oAPI.LogScriptEvent("Server_Discovery.vbs",101,0, "Starting in computername:" & ComputerName &_
" TargetComputer:" & TargetComputer & " IP:" & IP)
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' Check for the existence of Backup Exec Server
If (RegistryKeyExists("SYSTEM\CurrentControlSet\Services\BackupExecRPCService\") = True) Then
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' Found it? Then instantiate and set properties of a new object.
ver = GetVer(BEwin)
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' Added to discover only Releases prior to 15.0. For support of 15.0 version changed this condition to next version.
' And add latest release view to SCOM pack.
if ver < "15.0" and ver >= "11.0" then
bytecode = GetSTR("HARDWARE\DESCRIPTION\System\CentralProcessor\0", "Identifier")
path = GetSTR(BEwin & ver & "\Install\", "Path")
fullpath = "\\" & IP & "\" & replace( path, ":","$")
major = GetDW(BEwin & ver & "\Install\", "Build Major")
minor = GetDW(BEwin & ver & "\Install\", "Build Minor")
release = ""
if ver="14.0" then
ver = "2012"
end if
if ver="13.0" then
ver = "2010"
if major = 2896 then
release = ""
elseif major = 4164 then
release = " R2"
else
release = " R3"
end if
end if
if instr(bytecode, "64") > 0 then
bytecode = "64 Bit"
else
bytecode = "32 Bit"
end if
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.Server']$")
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/ComputerName$", ComputerName)
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/IP$", IP)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/ServiceName$", "BackupExecRPCService")
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/Version$", ver & release )
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/BuildMajor$", major )
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/BuildMinor$", minor )
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/Path$", fullpath)
call oInst.AddProperty("$MPElement[Name='Symantec_Backup_Exec_for_Windows_MPscom2007_PT.BaseClass']/ByteCode$", bytecode)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Symantec Backup Exec:Server " & ver & release & " (" & bytecode & ")")
call oDiscoveryData.AddInstance(oInst)
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' Deallocate the objects to avoid memory leak.
Set oAPI = Nothing
Set oDiscoveryData = Nothing
Set oInst = Nothing
Set oArgs = Nothing
Set oReg = Nothing
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' RegistryKeyExists(strKey) --> Returns True if strKey is present in the registry, otherwise False.
Function RegistryKeyExists(strKey)
Dim arrValueNames, arrValueTypes
' List all values inside the key. If key does not exist, then arrValueNames will continue a var, otherwise it will be an array
oReg.EnumValues HKEY_LOCAL_MACHINE, strKey, arrValueNames, arrValueTypes
' If it is an array, means that the key exists.
If isArray(arrValueNames) Then
RegistryKeyExists = True
Else
RegistryKeyExists = False
end if
End Function
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' GetVer(strKey) --> Returns a string containing the version of Backup Exec installed in the system.
Function GetVer(strKey)
Dim strKeyPath, arrSubKeys, subkey
' Enumerate all subkeys under strKey.
oReg.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
GetVer = ""
For Each subkey In arrSubKeys
'Locate the version by returning the name of the first key that starts with 1.
'It is predicted that it will support all versions from 10.0 to 19.9 AS LONG AS there is no
'other key that starts with 1.
if left(subkey,1) = "1" Then
GetVer = subkey
Exit For
end if
Next
End Function
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' GetDW(strKey, strValue) --> Returns a string containing the numerical value of the DWord.
Function GetDW(strKey, strValue)
Dim dwValue
oReg.GetDWORDValue HKEY_LOCAL_MACHINE, strKey, strValue, dwValue
GetDW = Cstr(dwValue)
End Function
' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' GetSTR(strKey, strValue) --> Returns the value of a string.
Function GetSTR(strKey, strValue)
Dim strRet
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKey, strValue, strRet
GetSTR = strRet
End Function</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>