bsharath
asked on
Get the wsus server the client gets updates from.
Hi,
Get the wsus server the client gets updates from.
I want help with a script when run on a specific set of machines checks registry and gets the wsus user name and machine name into a txt file
regards
raja
Get the wsus server the client gets updates from.
I want help with a script when run on a specific set of machines checks registry and gets the wsus user name and machine name into a txt file
regards
raja
ASKER
thanks
i get this
-------------------------- -
Windows Script Host
-------------------------- -
Script: D:\SUS path reg.vbs
Line: 7
Char: 2
Error: 0x80041003
Code: 80041003
Source: (null)
-------------------------- -
OK
-------------------------- -
i get this
--------------------------
Windows Script Host
--------------------------
Script: D:\SUS path reg.vbs
Line: 7
Char: 2
Error: 0x80041003
Code: 80041003
Source: (null)
--------------------------
OK
--------------------------
c:\computers.txt must contain one host name per line.
check if the hostnames are valid.
try this code:
check if the hostnames are valid.
try this code:
on error resume next
Const HKEY_LOCAL_MACHINE = &H80000002
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\computers.txt", 1)
Set objTextFile2 = objFSO.OpenTextFile ("c:\computersWSUS.txt", 2,true)
Do Until objTextFile.AtEndOfStream
strComputer = trim(objTextFile.Readline)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate"
strValueName = "WUServer"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objTextFile.WriteLine strComputer & " connects to WSUS Server:" & strValue
Set oReg=nothing
Loop
objTextFile.Close
objTextFile2.Close
ASKER
It keeps running and get no output
Should i change anything except the paths?
Should i change anything except the paths?
Try this. There were a couple of typo's in x-men's code.
Regards,
Rob.
Regards,
Rob.
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("computers.txt", 1)
Set objTextFile2 = objFSO.OpenTextFile ("computersWSUS.txt", 2,true)
Do Until objTextFile.AtEndOfStream
strComputer = trim(objTextFile.Readline)
On Error Resume Next
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
If Err.Number = 0 Then
strKeyPath = "Software\Policies\Microsoft\Windows\WindowsUpdate"
strValueName = "WUServer"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objTextFile2.WriteLine strComputer & " connects to WSUS Server:" & strValue
Else
objTextFile2.WriteLine strComputer & " is offline"
End If
Set oReg=nothing
Loop
objTextFile.Close
objTextFile2.Close
MsgBox "Done"
ASKER
Rob at some particular machines it gets stuck. anyways to skip those with the error logged
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rob for many i get has wmi error what could the solution be for the script to run fine and retrieve
You need to run the script using an account from the local administrators group of each machine (which should be the domain admin account).
If it still fails, then WMI errors need to be diagnosed with the WMI Diagnostic Tool.
Regards,
Rob.
If it still fails, then WMI errors need to be diagnosed with the WMI Diagnostic Tool.
Regards,
Rob.
Open in new window