TriggerSchedule Method on SCCM Clients

A really useful powershell snippet when creating deployments and testing application packages….

I was creating a Windows 7 image and wanted to add applications to the build task sequence, a base application set for the image, and once I had the packages created in SCCM I was using Advertised Programs to test the installations on a newly built image. To do this I was using a VMWare machine, so I was running the console for the client and in my impatience cycling the policy updates manually to see if the apps would deploy ok. Anyway I got annoyed with VMWare console mouse-handling on this machine and decided it would be much better to advertise the program then refresh the policy on the client with a powershell script.
A good friend of mine, we’ll call her Emma because that’s her name, wrote a neat little utility to invoke the TriggerSchedule methods on SCCM Clients, so I borrowed from that:
$tb_Client = “ClientPC”
$SMSCli = [wmiclass] “\\$tb_Client\root\ccm:SMS_Client”
# Machine Policy Retrieval & Evaluation

This works nicely on domain machines but my client was not yet domain-joined so I needed to pass credentials. Unfortunately the [wmi] and [wmiclass] type accelerators don’t allow you to pass credentials.

GWMI? That returns an instance but does not allow access to the static methods associated with the class.

Fortunately another good friend, Marc, was on hand to point me in the right direction.

“You need the class not the instance (as the class has the static methods you need)
But you need to do that remotely and the [WMICLASS] accelerator does not give you the option to authenticate with different credentials.
Solution is here to make the connection yourself, as that is more flexible as using the accelerator, using a management scope

In your case this would look like this :

$server = ‘Server’

$ms = new-object
$ms.path = “\\$server\root\CCM”

$options = $ms.Options
$Options.Username = ‘domain\user’
$Options.Password = ‘Password’

$ms.Options = $options

$mc = New-Object System.Management.ManagementClass($ms , ‘sms_client’,$null)

The next line, to generate a computer policy cycle is:

Fantastic, we all get by with help from our friends.

Thanks to Emma Harlow and Marc van Orsouw for this blog post.

Please check out