Status Filter Rules not applying ?
Hello, I am using OSD to deploy Windows and created the 2 following Status Filter Rules :
One that will send me an email via SMTP when a Task Sequence fails. It is triggered by Message ID # 11170 and will run a VBSscript that will send me a notifcation email...
One that will automatically delete a computer from the Deployment collection after being imaged. It is triggered by Message ID # 11171 and runs a VBScript that deletes the computer object from the collection ID.
Both rules are on the top of the list of priorities and have « Report to the event log » checked. The first rule works fine. The second rule doesn't seem to work. If I run it manually, it works fine so it is not a script issue. I even
get an eventlog entry saying that computer X will be deleted from collection Y and gets deleted. I check in the event log and when a computer is imaged, I see a message with ID 11171, meaning that the Task Sequence was successful but for some reason,
that rule doesn't seem to apply (this rule is on the top of all the rules!)
Any idea on what/where I could check to know why it is not running? (I double checked the message ID, no typo there...)
Thanks for the help!
July 26th, 2011 3:36pm
I just saw someone else doing something similar last week. This guy is actually adding a script into the TS to handle sending the emails. He said it works well. I'll try to dig up that post.
John Marcum | http://myitforum.com/cs2/blogs/jmarcum/|
Free Windows Admin Tool Kit Click here and download it now
July 26th, 2011 4:01pm
John, are you talking about this post
http://blog.danovich.com.au/2010/03/12/send-sccm-task-sequence-email-report/Bechir Gharbi | http://myitforum.com/cs2/blogs/bgharbi/ | Time zone : GMT+1
July 26th, 2011 4:17pm
The one I saw was on the myitforum.com SMS mailing list. I posted there and several people replied. I pointed them here. The one I saw added a script right into the TS. The script sent customized emails depending upon whether the TS failed or succeded.
John Marcum | http://myitforum.com/cs2/blogs/jmarcum/|
Free Windows Admin Tool Kit Click here and download it now
July 26th, 2011 4:43pm
Johan blogged about doing this via MDT which can easily be done as well without MDT Integration just add the ZTIUtility.vbs script to your package and call the referenced script.
http://www.deploymentresearch.com/Blog/tabid/62/EntryId/19/Configure-MDT-2010-to-send-an-email-when-deployment-is-completed.aspx
Thanks,
BrandonBrandon Linton |http://myitforum.com/cs2/blogs/brandonlinton/default.aspx | MCTS - SCCM, MDT, AD
July 26th, 2011 5:29pm
In my TS's I have a group called "Gather Logs and StateStore on Failure" Inside that group I perform a few tasks such as remoning the comptuer from the collection, clearing the last PXE advertisement and copying the deployment logs up to a share.
All of those same actions are also performed in the State Restore group for successful deployments. It would be easy to use the steps outlined in Johans blog to send one type email for success and a different email for failures. Just place the send mail
step in each of those groups.
John Marcum | http://myitforum.com/cs2/blogs/jmarcum/|
Free Windows Admin Tool Kit Click here and download it now
July 27th, 2011 8:07am
Actually the problem is not about sending emails, this rule works
It is the one that is supposed to delete computers from the collection after they have been imaged? I see in the server logs that I imaged 3 laptops this morning and they have a 11171 entry in the event log saying that the Task Sequence completed successfully.
But the status filter rules never triggered ? If I run it manually from the server for one computer, it gets deleted.
It is just that, for some reason, that rule doesnt seem to get triggered while the other rule (the one that sends email) is working? When a computer is imaged, a 11171 entry gets added to the eventlog but the rule associated with this entry never starts
? Any idea on what I could check on the server to find why this one is not running???
July 27th, 2011 2:40pm
Hi,
When you "run it by hand" you are running it with your credentials, right? What happens if you run the vbscript under the SYSTEM context?
Have a look at this blog:
http://blog.danovich.com.au/2010/03/12/remove-computer-association-from-collection-after-sccm-task-sequence/ it gives us a working script and status filter rule definition on event 11171.
Also take this as a reference:
http://technet.microsoft.com/en-us/library/bb693758.aspx Command-Line Parameters for Status Filter Rules.
Hope this will help.
Thanks
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 3:34am
I opened a cmd in Local System Context and ran the script manually and it worked...but again, it never gets triggered when an event 11171 is generated, while the send email, for 11170 works?
July 29th, 2011 8:42am
I opened a cmd in Local System Context and ran the script manually and it worked...but again, it never gets triggered when an event 11171 is generated, while the send email, for 11170 works?
replace the mail script on the failure rule with something that can easily run, or report to the event log, do they fail to trigger correctly too?
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2011 3:20pm
Hmmm very weird.
The script that sends an email when an error occurs (Event ID 11170) works perfectly and every time. I copied this script (changed subject and description...) and assigned this to the status filter rules of a TS success (Event ID 11171) and it worked one
time / 5 ? As you can see in the image joined, a successfull TS completed at 1:49:58 and 2 seconds later, the script ran. Then, 3 other successful TS were at 1:55, 1:57 and 1:58 but nothing got triggered ? Could it be that there are too many things running
on the server and sometimes, the Status Filter rule doesn't run because the server is too busy running other stuff? (this Status Filter Rule is the first one on the top of the priorities...)...One thing though is that I know that hte script is working :) It
just doesn't get triggered every time a 11171 event ID is generated :(
August 5th, 2011 2:18pm
OK I found something interesting...it actually works for computers that already exist in SCCM (ie: If I select a computer from the the All Systems collection and add it to my Deployment collection, the script will run and the computer will get deleted)
It doesn't run for computers that have been imported (computers that are fresh out of the box from the manufacturer, that never been connected to our network).
Here's the script I run
Option Explicit
' Constants for type of event log entry
const EVENTLOG_INFORMATION = 4
Dim Args
Dim swbemLocator, SWbemServices, objCollection, oProviderLocation, oLocation
Dim strComputerName, arrComputers, objComputer, sCollectionIDs
Dim objDirectRule
Dim strmessage, objshell
Dim seventlog, sClearPxeflag
On Error Resume Next
'Should an eventlog entry be generated, set Seventlog=1
sEventlog = "1"
'CollectionIDs from which to remove the computer
sCollectionIDs = "AAA00173"
'------------------------------------------------------------
'Get Command Line arguments
Set args = WScript.Arguments
strComputername = args.Item(0)
If strComputerName = NULL then
If Seventlog = "1" then
strMessage = "Computer name seems to be null..."
objShell.LogEvent EVENTLOG_INFORMATION, strMessage
End IF
Wscript.quit
End if
'------------------------------------------------------------
'Main script
set objShell = CreateObject("WScript.Shell")
Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")
swbemLocator.Security_.AuthenticationLevel = 6 'Packet Privacy.
Set swbemServices = swbemLocator.ConnectServer(".", "root\SMS")
Set oProviderLocation = swbemServices.InstancesOf("SMS_ProviderLocation")
For Each oLocation In oProviderLocation
If oLocation.ProviderForLocalSite = True Then
Set swbemServices = swbemLocator.ConnectServer(oLocation.Machine, "root\sms\site_" + oLocation.SiteCode)
End If
Next
Set arrComputers = SWbemServices.ExecQuery("select * from SMS_R_System where Name='" & strComputerName & "' and Obsolete = 0")
If Seventlog = "1" then
strMessage = "Status Filter rule script ran"
objShell.LogEvent EVENTLOG_INFORMATION, strMessage
End IF
For Each objComputer In arrComputers
RemoveCollectionMembership objComputer.ResourceID
'Write to eventlog if Seventlog = 1
If Seventlog = "1" then
strMessage = strcomputername & " will be removed from the following collection ID's " & scollectionids
objShell.LogEvent EVENTLOG_INFORMATION, strMessage
End IF
Next
Set objCollection = Nothing
Set SWbemServices = Nothing
Set SWbemLocator = Nothing
Wscript.Quit
'------------------------------------------------
Sub RemoveCollectionMembership(intresourceid)
on error resume next
Dim mCollectionID, i
mCollectionID = Split (sCollectionIDs, ":")
for i = Lbound(mCollectionID) to UBound(mCollectionID)
Set objCollection = SWbemServices.Get("SMS_Collection='" & MCollectionID(i) & "'")
Set ObjDirectRule = SWbemServices.Get("SMS_CollectionRuleDirect").SpawnInstance_
ObjDirectRule.ResourceID = intresourceid
ObjCollection.DeleteMembershipRule objDirectRule
next
End Sub
'------------------------------------------------
WScript.Quit(0)
After checking back the script, I think the problem would be in that command
Set arrComputers = SWbemServices.ExecQuery("select * from SMS_R_System where Name='" & strComputerName & "' and Obsolete = 0")
So I added a simple entry to the event viewre ("Status filter ran") and it's there, but it doesn't seem to enter in the For right after ... like arrComputers would be null ?
Could it be possible that since I imported the computer, it doesn't exist in SMS_R_System. Is there a way I could check that ?
Thanks!
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2011 1:08pm
OK I found something interesting...it actually works for computers that already exist in SCCM (ie: If I select a computer from the the All Systems collection and add it to my Deployment collection, the script will run and the computer will get deleted)
It doesn't run for computers that have been imported (computers that are fresh out of the box from the manufacturer, that never been connected to our network).
After checking back the script, I think the problem would be in that command
Set arrComputers = SWbemServices.ExecQuery("select * from SMS_R_System where Name='" & strComputerName & "' and Obsolete = 0")
Could it be possible that since I imported the computer, it doesn't exist in SMS_R_System. Is there a way I could check that ?
Thanks!
I think it is there, try this wql query instead:
select * from sms_r_system where name="<NAME>" and (obsolete = 0 or obsolete is null)
That should help you select the client record.
To check out sms_r_system, use WBEMTEST to connect to the site servers WMI namespace, click connect, root\sms\site_<YOUR SITE CODE>, click query, write a query and run it
August 10th, 2011 2:21pm
Hello,
I am trying to do the same as you're first rule (send me an email via SMTP when a Task Sequence fails) but i don't get a mail send out. When I run the VBscript manually it works but with the status filter rule it will not work. Is it possible the share you're
first rule, so that I can use that ??
I hope you will...
thnx.
Free Windows Admin Tool Kit Click here and download it now
April 24th, 2012 2:23am
Hi Pierre,
I ran into the same issue, but since i'm not a coder i got problems with the syntax and cannot get the script to work so it deletes the imported computers..
can you send me the hole script?
Thanks in advance..
Br Jens
June 6th, 2012 10:00am
Hello Louis! Sorry for the delay in the answer... if you still need the info... I know your script is working fine since it works manually.
Here is what I ran in my status filter rule (I do this from memory since I did that in a previous job where I don't work anymore but I will need to implement this in the next few days where I work so I will confirm wether this is still good or not. In any
case, you can try this and I am pretty sure this is the correct thing!)
The command line I ran for the status filter rule was CSCRIPT.EXE C:\SCRIPTS\SendEmail.vbs %msgsys
Message ID : 11170
Component : Task Sequence Manager (I think for some reason Task Sequence Manager was not available in the dropdown so I might have used Unknown Component or just ignored this setting...)
Hope this helps!
Free Windows Admin Tool Kit Click here and download it now
June 29th, 2012 11:26am
Here you go :
Just replace what is in bold with your collection ID (not the name of the collection but the ID!)
Option Explicit
' Constants for type of event log entry
const EVENTLOG_INFORMATION = 4
Dim Args
Dim swbemLocator, SWbemServices, objCollection, oProviderLocation, oLocation
Dim strComputerName, arrComputers, objComputer, sCollectionIDs
Dim objDirectRule
Dim strmessage, objshell
Dim seventlog, sClearPxeflag
On Error Resume Next
'CollectionIDs from which to remove the computer
'Should an eventlog entry be generated, set Seventlog=1
sEventlog = "1"
sCollectionIDs = "ENTER YOUR COLLECTION ID HERE!!!"
'------------------------------------------------------------
'Get Command Line arguments
Set args = WScript.Arguments
strComputername = args.Item(0)
If strComputerName = NULL then
wscript.quit
End if
'------------------------------------------------------------
'Main script
set objShell = CreateObject("WScript.Shell")
Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")
swbemLocator.Security_.AuthenticationLevel = 6 'Packet Privacy.
Set swbemServices = swbemLocator.ConnectServer(".", "root\SMS")
Set oProviderLocation = swbemServices.InstancesOf("SMS_ProviderLocation")
For Each oLocation In oProviderLocation
If oLocation.ProviderForLocalSite = True Then
Set swbemServices = swbemLocator.ConnectServer(oLocation.Machine, "root\sms\site_" + oLocation.SiteCode)
End If
Next
Set arrComputers = SWbemServices.ExecQuery("select * from SMS_R_System where Name='" & strComputerName & "' and (obsolete = 0 or obsolete is null)")
For Each objComputer In arrComputers
RemoveCollectionMembership objComputer.ResourceID
'Write to eventlog if Seventlog = 1
If Seventlog = "1" then
strMessage = strcomputername & " will be removed from the following collection ID's " & scollectionids
objShell.LogEvent EVENTLOG_INFORMATION, strMessage
End IF
Next
Set objCollection = Nothing
Set SWbemServices = Nothing
Set SWbemLocator = Nothing
Wscript.Quit
'------------------------------------------------
Sub RemoveCollectionMembership(intresourceid)
on error resume next
Dim mCollectionID, i
mCollectionID = Split (sCollectionIDs, ":")
for i = Lbound(mCollectionID) to UBound(mCollectionID)
Set objCollection = SWbemServices.Get("SMS_Collection='" & MCollectionID(i) & "'")
Set ObjDirectRule = SWbemServices.Get("SMS_CollectionRuleDirect").SpawnInstance_
ObjDirectRule.ResourceID = intresourceid
ObjCollection.DeleteMembershipRule objDirectRule
next
End Sub
'------------------------------------------------
WScript.Quit(0)
June 29th, 2012 11:29am
Hi Pierre-Luc, (and the others)
First thanks for the reply. The script to move te computer out of the collection after a succ. OSD/TS seems to work. But as I mentioned before I have made a task sequence which only install's our standard software after the OSD. The Task Sequence works fine,
but I dont get an email send out when the TS is finished. Do you perhaps can send me the code of this vbscript?. Now my script looks like this :
'==========================================================================
'
' VBScript Source File
'
' NAME: '
' AUTHOR: ' DATE : '
' COMMENT: script sends an e-mail in case of ended in success.
'
'==========================================================================
'Write out the log file
Set fso = CreateObject("Scripting.FileSystemObject")
Set ContactFile = fso.CreateTextFile("c:\temp\sendmail.txt", True)
ContactFile.WriteLine("script has started")
ContactFile.Close
On Error Resume Next
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "<Image Deployment - Windows 7 Ent x64>"
objMessage.Sender = """SCCM_OSD_Mailer"" <noreply@xxxxxx.com>"
objMessage.To = "myemailadres"
'objMessage.Bcc = ""
'objMessage.Cc = ""
objMessage.From = "noreply@xxxxxx.com"
objMessage.TextBody = "<Image Deployment - Windows 7 Ent x64 TS was successfull" & vbCRLF & vbCRLF & "automatic message"
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.XXXXXX.net"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
If Err.number <> 0 then
strMsg = "ERROR: ************ E-mail routine failed with Error: " & Err.Number & " - " & Err.description & " **************"
Else
strMsg = "E-mail was sent successfully"
End If
the status filter rule is started by this :
CSCRIPT.EXE D:\SccmScripts\testfilterrules\TSSucceeded_Email_Notification.vbs
component : task Sequence Manager
severity : Informational
message ID : 11171
Free Windows Admin Tool Kit Click here and download it now
July 1st, 2012 4:02pm
Hello! Here is the VBscript I use for sending me an email when a TS fails, just replace what is in bold with your infos.
Dim sComputerName
Set args = WScript.Arguments
sComputername = args.Item(0)
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Task sequence failed for: " & sComputername
objMessage.From = "sccm@yourdomain.com"
objMessage.To = "your@emailadress.com"
objMessage.TextBody = "There was a problem with a task sequence for the computer " & sComputername
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "yourSMTPserverhere"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
Status Filter Rule in SCCM:
CSCRIPT.EXE C:\SCRIPTS\SendEmailFailure.vbs %msgsys
Component : Task Sequence Manager
Severity : Informational
Message ID : 11170
and in case you want to receive an email when a TS is succesful, you will need to copy the SendEmailFailure.vbs and call it SendEmailSuccessful.vbs and change the text in the objMessage.Subject to something like
objMessage.Subject = "Task sequence successful for: " & sComputername
and Create a new Status Filter rule in SCCM (point to the new VBS and Message ID 11171 instead of 11170)
CSCRIPT.EXE C:\SCRIPTS\SendEmailSuccess.vbs %msgsys
Component : Task Sequence Manager
Severity : Informational
Message ID : 11171
July 3rd, 2012 8:19am
Hi again Piere-Luc,
Excuses for asking again but I am not so well with scripting...When I run the script in primal script in debug mode this error comes back :
Untitled4.vbs(16, 2) Microsoft VBScript runtime error: Subscript out of range
as I take al look at the point where the script seems to fail it is here:
Dim sComputerName
Set args = WScript.Arguments
sComputername = args.Item(0)
especially the part beginning with sComputername, when I delete the small s it comes back with the same error like :
Untitled4.vbs(16, 1) Microsoft VBScript runtime error: Subscript out of range
pff what Im I doing wrong....???
thnx again for the help!
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2012 10:49am
Hello! if you simply double click on the script it is normal because no arguments are passed to the script. When you execute the script through the Status Filter rule, it passes %msgsys (which is the AD name of the machine from where the message was triggered)
as an argument : SendEmailSuccess.vbs %msgsys
To test it, open a DOS window and copy your VBS at the root of C:. Open a command prompt and type the following at C:\
C:\> SendEmailSuccess.vbs TESTCOMPUTER
Your argument will then be TESTCOMPUTER so the script will set sComputerName = TESTCOMPUTER so you should receive an email with Task sequence failed for: TESTCOMPUTER as a subject :)
Let me know how it goes!
July 10th, 2012 1:42pm
Hi,
That Works indeed, pff one step further I got the mail, but why does the script does not start throughout the status filter rule then?
Thank you for the help I appreciate that very much !
Louis
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2012 2:47pm
If you go on the server in the event viewer, can you see the OSD logs that has message IDs 11171 or 11170
Maybe you need to activate logging ==>
Go to Component Configuration
Double click Status Reporting
Under Client Component status reporting, enable the Log checkbox and All Milestones and Details.
Because that rule is triggered by those IDs...If it is not logged, those IDs are not present and the rule will never be triggered!
July 10th, 2012 3:51pm
yes ! i think we've got it...that option was not marked on, do i also have to enable the checkbox 'log details on failure' or only the checkbox report and log --> all Milestones.
Great, I hope this works, thank you so much for the help !!!
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2012 4:28pm
Hi,
This morning I was very curious whether the status filter rule now also would work. This morning at 09: 15 there was a task sequence finished and gave the eventcode 11171, but again there was no mail sent. I wondered whether the adaption of this setting
a reboot is required of the primary site server?
I'm really a bit sad because is am busy testing this for so long time and stil it does not work yet
July 11th, 2012 3:43am
Hmmm weird, mine did not require a reboot. We know for a fact that your script runs because you are able to do it manually...It is probably something related to the Status Filter Rule.
Can you post a screenshot of your Status Filter Rule property ? Maybe double check the path of the VBS (maybe you need some quotes if there are spaces in the path)? and also confirm that it runs on a 11171 Message ID ?
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2012 8:11am
hi there,
how do i attach an image in this forum?
July 11th, 2012 9:00am
When you reply to a message, at the top of the message box, just use the last icon at right...
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2012 9:16am
July 11th, 2012 9:18am
and the cmd line is like :
CSCRIPT.EXE D:\SccmScripts\SendEmailSuccess.vbs %msgsys
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2012 9:24am
Should work but I just remembered something from where I used to work... Everything was working fine with CSCRIPT.exe D:\SccmScripts\SendEmailSuccess.vbs %msgsys and at some point it stopped working. I had to put
C:\Windows\System32\cscript.exe D:\SccmScripts\SendEmailSuccess.vbs %msgsys to make it work again ?
I set it up with just cscript.exe this week where I am now working and it's working fine but you can give this a try.
Hopefully it'll work!
July 11th, 2012 9:58am
ok, but the script runs on a 2008 server so i searched where the cscript.exe was stored. It is in :C:\Windows\winsxs\wow64_microsoft-windows-scripting_31bf3856ad364e35_6.1.7600.16385_none_aeb1ef0f4e6bba1d
do I have to put that path in ?
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2012 10:14am
Yes, my path was for Win Server 2003 but just put the correct path for Windows 2008 :)
July 11th, 2012 10:30am
It is really a mistery why my status filter rule does not want to work. I guess everything is tried out now. Almost everthing is checked, and still got no mail send...
pfff, the other status filter rules I have applied, like remove the client from the unattended collection after an OSD works fine with the combination of a cscript and the rule. But unfortunately this rule is very imprtant for our organisation. Perhaps
I will make a case by Microsoft so they can take a look at it. otherwise i am out of sync.....
Do you perhaps have heard from others who have this issue also? Thank you so much for you're help, and if there is something that's coming into you're mind, please let me know.
Louis
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2012 11:54am
The only thing I would think of is maybe an access issue since it works in the context of your account but it doesn't seem to work from the SCCM server but I don't really know how to check for that and if there are really rights for SMTP server to send
email...
July 11th, 2012 1:06pm
Hi,
Do you know under which account the scripts on the sccm server are running? How can I find out/check ? Perhaps this account has no permissions to do this..?
Free Windows Admin Tool Kit Click here and download it now
July 12th, 2012 2:50am
Hmm maybe it could be the network account or local system from SCCM but I don't really know how to verify or confirm this...
July 12th, 2012 8:19am
Hi there,
I've got the sollution for my problem :)
What was the question ? the status filter rule stood beneath in the rule list, and thus was never triggerd....the reason I don't know, but now I have put it on top of the list and it works fine !!
Perhaps others have the same problem, so guys be aware of this.
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2012 2:32am