This Vbs script will write the following SMS client information to a Microsoft Excel spreadsheet:
Name, Client, Client Type, Client Version, IP Address, Last Logon User Domain
Last Logon User Name, MAC Addresses, Net bios Name, Operating System Name and Version, Previous SMSUUID, Resource Domain or Workgroup, SMS Assigned Sites,
SMS Installed Sites and SMS Unique Identifier.
The machine information will be collected from a text file called MachineList.Txt. You can also modify the script to prompt you for an individual machine name using the example found at the end of this post.
Vbs Script:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Name"
objExcel.Cells(1, 2).Value = "Client"
objExcel.Cells(1, 3).Value = "Client Type"
objExcel.Cells(1, 4).Value = "Client Version"
objExcel.Cells(1, 5).Value = "IP Address"
objExcel.Cells(1, 6).Value = "Last Logon User Domain"
objExcel.Cells(1, 7).Value = "Last Logon User Name"
objExcel.Cells(1, 8).Value = "MAC Addresses"
objExcel.Cells(1, 9).Value = "Net bios Name"
objExcel.Cells(1, 10).Value = "Operating System Name And Version"
objExcel.Cells(1, 11).Value = "Previous SMSUUID"
objExcel.Cells(1, 12).Value = "Resource Domain Or Workgroup"
objExcel.Cells(1, 13).Value = "SMS Assigned Sites"
objExcel.Cells(1, 14).Value = "SMS Installed Sites"
objExcel.Cells(1, 15).Value = "SMS Unique Identifier"
On Error Resume Next
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_xxx")
' Change xxx to your site code
Set colItems = objWMIService.ExecQuery("Select * from SMS_R_System",,48)
For Each objName in colItems
objExcel.Cells(intRow, 1).Value = objName.Name
objExcel.Cells(intRow, 2).Value = objName.Client
objExcel.Cells(intRow, 3).Value = objName.ClientType
objExcel.Cells(intRow, 4).Value = objName.ClientVersion
objExcel.Cells(intRow, 5).Value = objName.IPAddresses
objExcel.Cells(intRow, 6).Value = objName.LastLogonUserDomain
objExcel.Cells(intRow, 7).Value = objName.LastLogonUserName
objExcel.Cells(intRow, 8).Value = objName.MACAddresses
objExcel.Cells(intRow, 9).Value = objName.NetbiosName
objExcel.Cells(intRow, 10).Value = objName.OperatingSystemNameandVersion
objExcel.Cells(intRow, 11).Value = objName.PreviousSMSUUID
objExcel.Cells(intRow, 12).Value = objName.ResourceDomainORWorkgroup
objExcel.Cells(intRow, 13).Value = objName.SMSAssignedSites
objExcel.Cells(intRow, 14).Value = objName.SMSInstalledSites
objExcel.Cells(intRow, 15).Value = objName.SMSUniqueIdentifier
intRow = intRow + 1
Next
Set colItems = Nothing
Set objWMIService = Nothing
Loop
objExcel.Range("A1:O1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Collecting SMS client information for an individual prompted machine name:
To prompt for an individual machine name comment out the following in the script above as shown in the example:
'On Error Resume Next
'Set Fso = CreateObject("Scripting.FileSystemObject")
'Set InputFile = fso.OpenTextFile("MachineList.Txt")
'Do While Not (InputFile.atEndOfStream)
Then comment out the line that reads:
'strComputer = InputFile.ReadLine
as shown in the example above and replace it with this:
strComputer = InputBox("Enter Machine Name To Query")
Then comment the Loop statement at the very end of the script.
No Comments