Set colComputers = GetObject("LDAP://CN=Computers, DC=Domain, DC=com")
set fso=CreateObject("scripting.filesystemobject")
strTargetPath="c:\scripts\"
i=1
For Each objComputer in colComputers
strComputer = objComputer.CN
on error resume next
set fOut=fso.CreateTextFile(strTargetPath & strComputer & ".txt", true)
if Err.Number<>0 then
Err.Clear
set fOut=fso.CreateTextFile(strTargetPath & "INVALID_NAME" & i & ".txt", true)
i=i+1
fOut.WriteLine "Computer name: " & strComputer
fOut.WriteLine ""
end if
' ----------
'Sub KBcheck()
Const HKEY_LOCAL_MACHINE = &H80000002
'strComputer = "l-yairn"
Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB955839"
strValueName = "Installed"
objRegistry.GetDwordValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If IsNull(strValue) Then
fOut.WriteLine "No value - You should install KB955839"
Wscript.Echo "No value - You should install KB955839"
Else
If strValue = 1 then
'intValue = 3
'objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,intValue
' Wscript.Echo "value exist"
fOut.WriteLine "KB exist"
Wscript.Echo "KB exist"
End If
End If
if Err.Number=0 then
on error goto 0
'end sub
' -----------
else
Err.Clear
Wscript.Echo "Computer not available"
'fOut.WriteLine "Computer not available"
end if
on error goto 0
fOut.Close
set fOut=nothing
Next
set fso=Nothing
set fso=CreateObject("scripting.filesystemobject")
strTargetPath="c:\scripts\"
i=1
Const ADS_SCOPE_SUBTREE = 2
Const HKEY_LOCAL_MACHINE = &H80000002
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"SELECT Name FROM 'LDAP://DC=domain,DC=com' WHERE objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strComputer = objComputer.Name
On Error Resume Next
Set fOut=fso.CreateTextFile(strTargetPath & strComputer & ".txt", true)
If Err.Number<>0 Then
Err.Clear
Set fOut=fso.CreateTextFile(strTargetPath & "INVALID_NAME" & i & ".txt", true)
i=i+1
fOut.WriteLine "Computer name: " & strComputer
fOut.WriteLine ""
End If
' ----------
'Sub KBcheck()
'strComputer = "l-yairn"
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB955839"
strValueName = "Installed"
objRegistry.GetDwordValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If IsNull(strValue) Then
fOut.WriteLine "No value - You should install KB955839"
Wscript.Echo "No value - You should install KB955839"
Else
If strValue = 1 then
'intValue = 3
'objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,intValue
' Wscript.Echo "value exist"
fOut.WriteLine "KB exist"
Wscript.Echo "KB exist"
End If
End If
If Err.Number=0 Then
On Error GoTo 0
'end sub
' -----------
Else
Err.Clear
Wscript.Echo "Computer not available"
'fOut.WriteLine "Computer not available"
End If
On Error GoTo 0
fOut.Close
objRecordSet.MoveNext
Loop
Set fOut=Nothing
Set colComputers = GetObject("LDAP://CN=Compu