Saturday, October 25, 2008

ePO Duplicate GUID script

Here is a script that I have been asked about several times. You just have to put in your LDAP / OU structure, where you keep your computers and this will fix that problematic duplicate GUID problem.
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
'
'
' COMMENT: gets guids
'
'==========================================================================

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Define Constants
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim intRecCount
intRecCount = 0

LocalComputer = "."

''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''Create and load dictionary object
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Set objDictionary = CreateObject("Scripting.Dictionary")
'objDictionary.CompareMode = vbTextCompare
'Set objGUIDDict = CreateObject("Scripting.Dictionary")
'objGUIDDict.CompareMode = vbTextCompare
'
'
'
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'' Determine DNS domain name.
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Set objRootDSE = GetObject("LDAP://RootDSE")
'strDNSDomain = objRootDSE.Get("DefaultNamingContext")
'
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''Create connection and command objects
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Set objConnection = CreateObject("ADODB.Connection")
'objConnection.Open "Provider=ADsDSOObject;"
'Set objCommand = CreateObject("ADODB.Command")
'objCommand.ActiveConnection = objConnection
'objCommand.Properties("Page Size") = 100
'objCommand.Properties("Timeout") = 60
'objCommand.Properties("Cache Results") = False
'
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Define Search Query
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'strBase = ""
'strFilter = "(&(objectCategory=person)(objectClass=user))"
'strFilter = "(objectCategory=computer)"
'strAttributes = "name,userAccountControl"
'strQuery = strBase & ";" & strFilter & ";" & strAttributes
'
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''Execute command and build recordset
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'objCommand.CommandText = strQuery
'Set objRecordSet = objCommand.Execute
'Wscript.echo "-----------------------------------------------------"
'Wscript.echo "Running AD Query ..."
'Do until objRecordSet.EOF
' intRecCount = intRecCount + 1
' 'Wscript.StdOut.Write(".")
' strCN = objRecordSet.Fields("name")
' intUAC=objRecordSet.Fields("userAccountControl")
' if intUAC AND ADS_UF_ACCOUNTDISABLE Then
' AcctStat="Disabled"
' Else
' AcctStat="Enabled"
' End If
' If AcctStat="Enabled" Then
' errValue = Ping(strCN)
' If errValue = "Online" Then
' 'WScript.Echo strCN
' strRegValue=RegListValueString(strCN)
' 'WScript.Echo strRegValue
' 'add items to dictionary
' 'objDictionary.add strCN, strRegValue
' If strRegValue="" Or IsNull(strRegValue) Then
' WScript.Echo strCN & " " & strRegValue & " - Null"
' ElseIf objGUIDDict.Exists(strRegValue) Then
' WScript.Echo strCN & " " & strRegValue & " - Duplicate"
' Call RegDeleteValue(strCN)
' Call StopService(strCN,"McAfeeFramework")
' Call StartService(strCN,"McAfeeFramework")
' On Error Resume Next
' Set osvcRemote = GetObject("winmgmts:\\" & strCN & "\root\cimv2")
' Set oprocess = osvcRemote.Get("win32_process")
' ret = oprocess.create("c:\\program files\\network associates\\common framework\\cmdagent.exe /P")
' if (ret <> 0) Then
' 'wscript.echo "Failed to start process on " & strCN & ": " & ret
' Else
' 'wscript.echo "Started process on " & strCN & ": " & ret
' End If
' Else
' objGUIDDict(strRegValue) = True
' WScript.Echo strCN & " " & strRegValue & " - Healthy"
' End If
' End If
' End If
' objRecordSet.movenext
'Loop
'WScript.Quit
'
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''Build a dictionary of the unique GUIDS
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'For Each GUID in objDictionary.Items
' 'WScript.Echo GUID
' objGUIDDict(GUID) = True
'Next
'
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''Compare guids to computernames and return all computers for each guid
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'For Each strMgrName In OBJGUIDDICT.Keys
' strMbxName = ""
' index = 0
' ReDim arrayGUIDS(0, index)
' For Each strMbxName In OBJDICTIONARY
' If OBJDICTIONARY.item(strMbxName) = strMgrName Then
' 'WScript.Echo "Matched guid " & strMgrName & " " & strMBXName
' ReDim Preserve arrayGUIDS(0, index)
' arrayGUIDS(0, index) = strMBXName
' index = index + 1
' End If
' Next
' If index > 1 Then
' WScript.Echo strMgrName & " has more then 1 member."
' For Each strcomputername In arrayguids
' WScript.Echo strcomputername
' call RegDeleteValue(strComputername)
' call StopService(strcomputername,"McAfeeFramework")
' Call StartService(strcomputername,"McAfeeFramework")
' On Error Resume Next
' Set osvcRemote = GetObject("winmgmts:\\" & strcomputername & "\root\cimv2")
' Set oprocess = osvcRemote.Get("win32_process")
' ret = oprocess.create("c:\\program files\\network associates\\common framework\\cmdagent.exe /P")
' if (ret <> 0) Then
' wscript.echo "Failed to start process on " & strcomputername & ": " & ret
' Else
' wscript.echo "Started process on " & strcomputername & ": " & ret
' End If
' Err.Clear
' Next
' End If
'Next
'
'wscript.echo "Completed query - total records: " & intRecCount
'
'Function RegListValueString(strComputer)
' On Error Resume Next
' Const HKEY_LOCAL_MACHINE = &H80000002
' strKeyPath = "SOFTWARE\Network Associates\ePolicy Orchestrator\Agent"
' strValueName = "AgentGUID"
' Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
' strComputer & "\root\default:StdRegProv")
'
' oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
' RegListValueString = strValue
'End Function
'
'Function RegDeleteValue(strComputer)
' On Error Resume Next
' Const HKEY_LOCAL_MACHINE = &H80000002
' strKeyPath = "SOFTWARE\Network Associates\ePolicy Orchestrator\Agent"
' strValueName = "AgentGUID"
' Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
' strComputer & "\root\default:StdRegProv")
'
' oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName
'End Function
'
'Function Ping(remoteComputer)
' Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & LocalComputer & "\root\cimv2")
' Set colPingedComputers = objWMIService.ExecQuery("Select * from Win32_PingStatus Where Address = '" & remoteComputer & "'")
'
' For Each objComputer in colPingedComputers
' If objComputer.StatusCode = 0 Then
' Ping = "Online"
' Else
' Ping = "Offline"
' End If
' Next
' End Function
'
'
'Function StopService(strComputer, Service)
' On Error Resume Next
' Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Set colServiceList = objWMIService.ExecQuery("Associators of " _
' & "{Win32_Service.Name='" & Service & "'} Where " _
& "AssocClass=Win32_DependentService " & "Role=Antecedent" )
' On Error Resume Next
' For Each objService in colServiceList
' If (objService.State = "Stopped") Then
' 'wscript.echo "Dependant service " & objService.name & " is " & objService.State
' Exit For
' End If
' 'wscript.echo "Stopping dependent service: " & objService.Name & " ..."
' objService.StopService()
' wscript.sleep 1000
' Next
' wscript.sleep 2000
'
' Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service where Name= '" & Service & "'")
' For Each objService in colServiceList
' If (objService.State = "Stopped") Then
' 'wscript.echo objService.name & " service is " & objService.State
' Exit For
' End If
' 'wscript.echo "Stopping " & Service & " service ..."
' errReturn = objService.StopService()
' Next
'End Function
'
'Function StartService(strComputer, Service)
' On Error Resume Next
' Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service where Name= '" & Service & "'")
'
' For Each objService in colServiceList
' If (objService.State = "Running") Then
' 'wscript.echo objService.name & " service is " & objService.State
' Exit For
' End If
' 'wscript.echo "Starting " & Service & " ..."
' errReturn = objService.StartService()
' Set colDepServiceList = objWMIService.ExecQuery("Associators of " _
' & "{Win32_Service.Name='" & Service & "'} Where " _
' & "AssocClass=Win32_DependentService " & "Role=Antecedent" )
' For Each objDepService in colDepServiceList
' If (objDepService.State = "Running") Then
' wscript.echo "Dependant service " & objDepService.name & " is " & objDepService.State
' Exit For
' End If
' 'wscript.echo "Starting dependent service: " & objDepService.Name & " service ..."
' objDepService.StartService()
' Next
' Next
' wscript.sleep 2000
'End Function

This will check the system, keep track of the GUID and replace it if there is a duplicate.

Tuesday, October 14, 2008

My Dog - My Dad

It has been a real crappy end of the year. As you know, my father has cancer and has been really struggling these past several weeks. I feel that time is short. My sister came into town last week to spend time with all of us. We had a nice family dinner with all of us talking and having my kids run around. He sure likes to watch them, brings a smile to his heart. I have been trying to spend as much time as possible over there and talk to him about everything but his health or his physical health. What is there to say? Feel like crap… Tonight, I will be heading over there after work to spend time there and have dinner.

About two weeks ago, Freya had a growth on the side of her jaw. I took her to the vet, who did a biopsy to figure out what it was, but it came back inconclusive. Last Tuesday, the vet wanted to remove it and send the entire thing as a sample. It grew to double the size of the prior week, so he just took enough to get a better idea of what it may be. When we where there, he said that it could be one of eight things, seven of which are fatal. Freya has been sleeping a lot, more than normal and wanting to be under me or my wife. This means that she is not feeling well. I have been giving her wet food to make sure that she has been eating. With a big thing in her mouth, I can understand that she would not want to eat this dry crunchy dog food. Last night, we got the test results back, it is cancer. The vet said that the treatment would begin with removing her jaw and beginning chemotherapy. I just can’t do that to my dog. I see what this is doing to my dad, I just can’t do it to my dog. So, we are going to have to put Freya down. It is the most humane thing to do.

And the hits keep on coming!