Rerun advertisement when program runtime has previously been exceeded
When a mandatory advertised program times out in SCCM 2007, it’s not rerun on client unless advertisement is configured to “Always Rerun Program”. When program fails with “run time exceeded” error the status message with ID 10070 is generated that says something like this:
The program for advertisement "ADV00001" ("PKG00001" – "Install My Program") exceeded the maximum allowed run time of 30 minute(s). Systems Management Server (SMS) has stopped monitoring the program, and is unable to determine the status of the program. SMS will not automatically attempt to run this program again.
Advertisements are usually configured to “Rerun if failed previous” and as program timeout is considered a failure, it won’t be rerun any more. There are cases when “Maximum allowed run time” can’t be increased too high because it could exceed the length of any available maintenance windows and then program is never run. Sometimes it would be required to rerun the program if it could be something that awaits user input on purpose, or there could be other known factors causing the occasional timeouts. I don’t necessarily want to initiate rerun manually on client side or by creating new advertisement every time. Here’s one way how to automatically rerun program even if it has timed out earlier…
The approach requires two advertisements and two target collections, but I think it’s small price to pay for the cause.
First I’ve set up two collections for software distribution:
The “Install My Software” collection is for the normal software distribution where all the target computers belong to. Now the “Rerun My Software” will only contain computers where advertisement previously failed because of exceeded run time. This collection uses dynamic query that filters out computers that have returned specific status message for either of two advertisements. Which two advertisements? I’m getting there.
Before specifying the query for “Rerun My Software” collection, create two advertisements:
| Target Collection | Rerun behavior | Advertisement ID | |
| Normal deployment | Install My Software | Rerun if failed previous | ADV00001 |
| Rerun deployment | Rerun My Software | Always Rerun Program | ADV00002 |
Once the advertisements are ready, record their IDs as these are needed for the “Rerun My Software” collection query. So if advertisements use the IDs according to table above, the query will be:
select SYS.ResourceID,SYS.ResourceType,SYS.Name,SYS.SMSUniqueIdentifier,SYS.ResourceDomainORWorkgroup,SYS.Client
from sms_r_system as sys inner join SMS_ClientAdvertisementStatus as offer
on sys.ResourceID=offer.ResourceID
WHERE
(AdvertisementID = 'ADV00001' AND LastStatusMessageID = 10070
AND SYS.ResourceID NOT IN
(SELECT ResourceID FROM SMS_ClientAdvertisementStatus
WHERE AdvertisementID = 'ADV00002' AND
(LastState = 11 OR LastState = 13) AND LastStatusMessageID <> 10070)
) OR
(AdvertisementID = 'ADV00002' and LastStatusMessageID = 10070)
Notice that in this query I have excluded computers that have failed “Rerun deployment” for other reason than timeout and those that have run the program successfully.
Also make sure that “Rerun My Software” collection has “Update this collection on a schedule” enabled. The update interval should be less than client policy polling interval so that the computers that have run the program successfully would be gone from this collection before next rerun occurs. For example, as default policy polling interval is 60 minutes, I used 15 minutes update interval on a collection.
That’s it. Now if the normal deployment fails on a client because of “Program failed (run time exceeded)”, the second advertisement (Rerun deployment) will take over and continue running the program as long as the program keeps timing out.