Retrieving SMS Group Discovery Information And Writing It To An Excel Spreadsheet

 

This Vbs script which is the equivalent of executing the SQL Script below will return the Group name, AD domain and NT  domain name for all SMS discovered Groups to an excel spreadsheet.

 

SQL Script:

 

Select

Usergroup_Name0 'Group Name',

Active_Directory_Domain0 'AD Domain',

Windows_NT_Domain0 'NT Domain'

From User_Group_Disc

 

VBS Script:

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Group Name"

objExcel.Cells(1, 2).Value = "AD Domain"

objExcel.Cells(1, 3).Value = "NT Domain"

 

strComputer = InputBox("Enter Site Server Name")

strSiteCode = InputBox("Enter Site Code")

 

Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)

Set colItems = objWMIService.ExecQuery("Select * From SMS_R_UserGroup")

 

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = objItem.UsergroupName

objExcel.Cells(intRow, 2).Value = UCase(objItem.ActiveDirectoryDomain)

objExcel.Cells(intRow, 3).Value = UCase(objItem.WindowsNTDomain)

intRow = intRow + 1

Next

 

objExcel.Range("A1:C1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

 

Published Sunday, April 29, 2007 11:46 AM by dhite
Filed under:

Comments

No Comments