To All-
I'm trying to get the primary server name. I have 2 server, a backup and a primary per location.
I'm getting the backup server name instead of the primary.
The last 3 digits of the ip address tell identify the server, 195 is the primary.
below is the script.
Thanks for any help I can get.
Tony
Sub ShowSVRIPAddress
strComputer = "."
Set objIPaWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colIPaItems = objIPaWMIService.ExecQuery("Select * from Win32_NTDomain",,48)
For Each IPAobjItem in colIPaItems
tmpsvripaddr = IPAobjItem.DomainControllerAddress
if Right(tmpsvripaddr,3) > 0 then
svripaddr = Left(tmpsvripaddr,(Len (tmpsvripaddr)-3)) & 195
svripaddr1 = Right(svripaddr,(Len(svripaddr)-2))
if Right(svripaddr,3) = 195 then
strComputer = svripaddr1
ShowSVRName strComputer
end if
end if
next
set objIPaWMIService = Nothing
End Sub
'============================================================================
'
' S h o w S V R N a m e
' =======================
'
'
Sub ShowSVRName(svripaddr1)
Set objSVRnWMIService = GetObject( _
"winmgmts:{impersonationLevel=impersonate," _
& "authenticationLevel=pktPrivacy}!root/cimv2")
Set colSVRnItems = objSVRnWMIService.ExecQuery ("Select * from Win32_NTDomain",,48)
For Each SVRNobjItem in colSVRnItems
tmpsvrname = SVRNobjItem.DomainControllerName
next
set objSVRnWMIService = Nothing
End Sub
I'm trying to get the primary server name. I have 2 server, a backup and a primary per location.
I'm getting the backup server name instead of the primary.
The last 3 digits of the ip address tell identify the server, 195 is the primary.
below is the script.
Thanks for any help I can get.
Tony
Sub ShowSVRIPAddress
strComputer = "."
Set objIPaWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colIPaItems = objIPaWMIService.ExecQuery("Select * from Win32_NTDomain",,48)
For Each IPAobjItem in colIPaItems
tmpsvripaddr = IPAobjItem.DomainControllerAddress
if Right(tmpsvripaddr,3) > 0 then
svripaddr = Left(tmpsvripaddr,(Len (tmpsvripaddr)-3)) & 195
svripaddr1 = Right(svripaddr,(Len(svripaddr)-2))
if Right(svripaddr,3) = 195 then
strComputer = svripaddr1
ShowSVRName strComputer
end if
end if
next
set objIPaWMIService = Nothing
End Sub
'============================================================================
'
' S h o w S V R N a m e
' =======================
'
'
Sub ShowSVRName(svripaddr1)
Set objSVRnWMIService = GetObject( _
"winmgmts:{impersonationLevel=impersonate," _
& "authenticationLevel=pktPrivacy}!root/cimv2")
Set colSVRnItems = objSVRnWMIService.ExecQuery ("Select * from Win32_NTDomain",,48)
For Each SVRNobjItem in colSVRnItems
tmpsvrname = SVRNobjItem.DomainControllerName
next
set objSVRnWMIService = Nothing
End Sub