Скрипт бежит по домену, подключается к компьютерам, считывает информацию о лицензировании, выводит в консоль в формате CSV
Наздоровье
[code]strComputer=""
strFilter=""
strQuery=""
On Error Resume Next
Set objDomain=Getobject("WinNT://DOMAIN")
For Each object In objDomain
If object.Class="Computer" Then
strComputer=object.Name
strWin=GetWindowsStatus
strOff=GetOfficeStatus
Wscript.echo strComputer & ";" & strWin & ";" & strOff
End If
Next
Function GetActivationStatus
On Error Resume Next
On Error Goto 0
Err.Clear
Status="Not found"
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
If Err.Number=0 Then
i=0
Set col = objWMI.ExecQuery(strQuery)
Status="Not activated"
For Each obj in col
i=i+1
If obj.LicenseStatus=1 Then Status="Activated": Exit For
Next
If i=0 Then Status="Not Found"
End If
GetActivationStatus=Status
End Function
Function GetWindowsStatus
strFilter="Windows"
strQuery="SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE Description like '%" & strFilter & "%'"
strGWS=GetActivationStatus
GetWindowsStatus=strGWS
End Function
Function GetOfficeStatus
strFilter="Office"
strQuery="SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE Description like '%" & strFilter & "%'"
strGOS=GetActivationStatus
GetOfficeStatus=strGOS
End Function
[/code]