Function GetLogonServer()
On Error Resume Next
Dim strComputerDom, objWMIService, colItemsDom, objitemDom, strGetDomain
strComputerDom = "."
strGetDomain = "Domain: " & GetDomain
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerDom & "\root\cimv2")
Set colItemsDom = objWMIService.ExecQuery("Select Name,DomainName,DomainControllerName from Win32_NTDomain Where Name='" & strGetDomain & "' ")
For Each objitemDom In colItemsDom
GetLogonServer = objitemDom.DomainControllerName
Exit For
Next
End Function
Above vbscript gets the Logon Server name. This is tested and confirm to work fine
On Error Resume Next
Dim strComputerDom, objWMIService, colItemsDom, objitemDom, strGetDomain
strComputerDom = "."
strGetDomain = "Domain: " & GetDomain
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerDom & "\root\cimv2")
Set colItemsDom = objWMIService.ExecQuery("Select Name,DomainName,DomainControllerName from Win32_NTDomain Where Name='" & strGetDomain & "' ")
For Each objitemDom In colItemsDom
GetLogonServer = objitemDom.DomainControllerName
Exit For
Next
End Function
Above vbscript gets the Logon Server name. This is tested and confirm to work fine
No comments:
Post a Comment