This VBS script will allow you to enter a Site server name and Site code into input dialog boxes and will then locate all machines that have a shared or duplicate Globally Unique Identifier (GUID) and send the old and new machine names to excel.
For additional information see the link at the end of this post.
VBS Script:
strServer = InputBox ("Enter Site Server Name")
strDatabase = InputBox ("Enter Three Letter Site Code")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Old Name"
objExcel.Cells(1, 2).Value = "New Name"
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB;Data Source =" & strServer & ";" & _
"Trusted_Connection=Yes;Initial Catalog =SMS_" & strDatabase
Set objRecordSet = CreateObject("ADODB.Recordset")
objRecordSet.Open "Select Distinct SH.Name0 Old, SD.Name0 New" & _
" From System_Data SD" & _
" Join System_Hist SH on SH.MachineId = SD.MachineId" & _
" And SD.Name0 Not Like SH.Name0" , objConnection, adOpenStatic, adLockOptimistic
Do Until objRecordSet.EOF
objExcel.Cells(intRow, 1).Value = objRecordSet.Fields("Old").Value
objExcel.Cells(intRow, 2).Value = objRecordSet.Fields("New").Value
objRecordSet.MoveNext
intRow = intRow + 1
Loop
objExcel.Range("A1:B1").Select
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
Set objRange = objExcel.Range("A1")
objRange.Sort objRange,1,,,,,,1
MsgBox "Done"
Managing Duplicate Globally Unique Identifiers in Systems Management Server 2003
http://www.microsoft.com/downloads/details.aspx?FamilyID=AAF6F10D-BD84-405E-9AF3-B48CED1D7F2D&displaylang=en
No Comments