Windows 7 Run ReRun SCCM SMS Advertisement to client

Powershell
First you need a dump of available stuff and you must specify a username/password not rely on the normal 'impersonating' function.

You need two things depending on what you are doing, viz 'PackageID', 'ProgID' (Listed as just 'Id') for each program.

In this example ,PackageID = UL10008D, ProgID = "MSI Install"

Check you have the right info with this that should just return one package. [with .GetProgram($ProgID, $PackageID)]

You will get something dumped like this

Id                      : MSI Install Name                    : MSI Install Version                 : AdditionalRequirements  : DependentProgId         : Enabled                 : 1 EstimatedDiskSpace      : MaxRuntime              : 7200 CompletionAction        : 0 StartTime               : 13/03/2012 15:39:00 ExpiryTime              : 01/01/1970 00:00:00 RequiresUserInput       : 1 PackageId               : UL10008D PackageName             : Acrobat X Pro PackagePublisher        : PackageLanguage         : DependentPackageId      : FullName                : Acrobat X Pro - MSI Install  IsOSDProgram            : 0 IsAssigned              : 1 BalloonRemindersRequired : 0 ContentSource           : 69

Some logged in on target
Now this only works without someone logged in to the remote target, which isn't so useful.

No one logged in on target
This is far more useful as you can just run anything when the remote machine is switched on.

It also doesn't need psexec and doesn't need an further credential passing. (The account im running psexec from is in admin group on target, not sure if this matters)

This relies on the dll (smsclictr.automation.DLL) from SCCM Client Centre being available, in my case from 'C:\Program Files\SCCM Tools\SCCM Client Center\smsclictr.automation.DLL'

You also need to find the 'Advertisement ID' before you can use it. [function is .RerunAdv(AdvertisementID, PackageID, ProgramID ] (I cheated at this point and looked in SCCM Client centre for it, I am sure its easy enough to find though!!)

As a one liner;

Broken down bit by bit;

"UL120034-UL10008D-B9A3E532" is returned when its worked!

VB
You can do all the above with VB, I dislike VB though so this is just for info on how to trigger an install remotely...

A user MUST be logged in to the target PC for this to work, then run following via psexec passing credentials.

psexec -u dom\username -p password \\host cscript runadv.vbs

runadv.vbs

You can also load the DLL as above with powershell and do the same, I didn't though as PS was good enough for me.

=Comments=