i have used the attached VBS to do a very simple task, i created an empty computer collection in SCCM, added a text file of users from active directory, ran the script and it would check the last computer login of each user in the last and add it to the collection.
This script ran well in a completely different domain environment and with SCCM 2007, now i have a new domain with SCCM2012, and when i ran it i always get "User not found".
anyone have any idea on what i need to do to modify the script\my environment so it will work?
on error resume next
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("Test.txt", ForReading, True, TristateUseDefault)
Do While file.AtEndOfStream <> True
comname = file.readline
Set lLocator = CreateObject("WbemScripting.SWbemLocator")
Set gService = lLocator.ConnectServer(, "root\sms\SERVER_CODE")
ResID = 0
Set Computers = gService.ExecQuery("Select * From SMS_R_system WHERE LastLogonUserName LIKE ""%" + comname + "%""")
For Each Comp In Computers
If UCase(comp.LastLogonUserName) = UCase(comname) Then ResID = comp.ResourceID
If ResID = 0 Then WScript.echo "not found:" + comname
Set CollectionRule = gService.Get("SMS_CollectionRuleDirect").SpawnInstance_()
CollectionRule.ResourceClassName = "SMS_R_System"
CollectionRule.RuleName = "ResourceID=" & ResID
CollectionRule.ResourceID = ResID
Set oCollectionSet = gService.ExecQuery("Select * From SMS_Collection")
For Each oCollection In oCollectionSet
' WScript.Echo oCollection.Name
If oCollection.Name = newname Then
If Err.Number = 0 Then
Wscript.Echo comname + " were added to the " + oCollection.Name + " collection!"
Thanks in advance.