Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permission denied error code 800a0046

Status
Not open for further replies.

tbscmgi

MIS
Sep 17, 2003
66
US
To All-
I get permission denied when I'm trying to get the server name.
Thanks for any help.
tbscmgi


********************************************************
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))
end if
next
set objIPaWMIService = Nothing
End Sub
'============================================================================
'
' S h o w S V R N a m e
' =======================
'
'
Sub ShowSVRName
Set objSVRnWMIService = GetObject( _
"winmgmts:{impersonationLevel=impersonate," _
& "authenticationLevel=pktPrivacy}!\\" & svripaddr1 & "\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
 
Are you looking for generic domain controller names or the login server name?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top