VBS Script To Send Basic SMS Or ConfigMgr Site Server Information To A Word Document

 

This VBS Script will allow you to enter a site server name and site code into input dialog boxes and will write basic site server information to a word document. The script as written will allow you to document your site server information and save the results for your reference.

 

VBS Script:

 

strComputer = InputBox ("Enter Site Server Name")

strSiteCode = InputBox ("Enter SMS Site Code")

 

Const NUMBER_OF_ROWS = 17

Const NUMBER_OF_COLUMNS = 2

 

Set objWord = CreateObject("Word.Application")

objWord.Visible = True

Set objDoc = objWord.Documents.Add()

 

Set objRange = objDoc.Range()

objDoc.Tables.Add objRange, NUMBER_OF_ROWS, NUMBER_OF_COLUMNS

Set objTable = objDoc.Tables(1)

objTable.Cell(1,1).Range.Text = "System Information For: "

objTable.Cell(2,1).Range.Text = "Manufacturer"

objTable.Cell(3,1).Range.Text = "Model"

objTable.Cell(4,1).Range.Text = "Domain"

objTable.Cell(5,1).Range.Text = "Domain Type"

objTable.Cell(6,1).Range.Text = "Total Physical Memory"

objTable.Cell(7,1).Range.Text = "Processor Manufacturer"

objTable.Cell(8,1).Range.Text = "Processor Name"

objTable.Cell(9,1).Range.Text = "Processor Clock Speed"

objTable.Cell(10,1).Range.Text = "Server Name"

objTable.Cell(11,1).Range.Text = "Site Name"

objTable.Cell(12,1).Range.Text = "Site Code"

objTable.Cell(13,1).Range.Text = "Type"

objTable.Cell(14,1).Range.Text = "Build Number"

objTable.Cell(15,1).Range.Text = "Version"

objTable.Cell(16,1).Range.Text = "Install Directory"

objTable.Cell(17,1).Range.Text = "Parent"

 

' Machine Information

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

For Each objItem in colItems

objTable.Rows.Add()

objTable.Cell(1, 2).Range.Text = UCase(strComputer)

objTable.Cell(2, 2).Range.Text = objItem.Manufacturer

objTable.Cell(3, 2).Range.Text = objItem.Model

objTable.Cell(4, 2).Range.Text = objItem.Domain

Select Case objItem.DomainRole

Case 0 strComputerRole = "Standalone Workstation"

Case 1 strComputerRole = "Member Workstation"

Case 2 strComputerRole = "Standalone Server"

Case 3 strComputerRole = "Member Server"

Case 4 strComputerRole = "Backup Domain Controller"

Case 5 strComputerRole = "Primary Domain Controller"

End Select

objTable.Cell(5, 2).Range.Text = strComputerRole

objTable.Cell(6, 2).Range.Text = FormatNumber(objItem.TotalPhysicalMemory/1024/1024,1) & " MB"

Next

 

' Processor Information

Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")

For Each objItem in colItems

objTable.Cell(7, 2).Range.Text = objItem.Manufacturer

objTable.Cell(8, 2).Range.Text = objItem.Name

objTable.Cell(9, 2).Range.Text = Round(objItem.MaxClockSpeed) & " MHz"

Next

 

' Site Information

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

Set colItems = objWMIService.ExecQuery("Select * from SMS_Site")

For Each objItem in colItems

objTable.Cell(10, 2).Range.Text = objItem.ServerName

objTable.Cell(11, 2).Range.Text = objItem.SiteName

objTable.Cell(12, 2).Range.Text = objItem.SiteCode

If objItem.Type = 1 Then

objTable.Cell(13, 2).Range.Text =  "Secondary"

Else

objTable.Cell(13, 2).Range.Text =  "Primary"

End If  

objTable.Cell(14, 2).Range.Text = objItem.BuildNumber

objTable.Cell(15, 2).Range.Text = objItem.Version

objTable.Cell(16, 2).Range.Text = objItem.InstallDir

objTable.Cell(17, 2).Range.Text = objItem.ReportingSiteCode

Next

 

objTable.AutoFormat(23)

 

 

Published Sunday, January 27, 2008 12:59 PM by dhite
Filed under:

Comments

No Comments