I wrote a script to handle a cluster patching situation where I needed to give a server owner the ability to run the ConfigMgr monthly patch management task sequence on-demand (immediately) via PowerShell. The server owner would use another script to make their machine, in this case a cluster joined virtual server host, ready for patching (resources drained, removed from the cluster, etc.) and then initiate the patch task sequence to install any required security updates. At the end of the task sequence a post-patching script will make the server ready for production (rejoin the cluster) so they can continue onto the next host programmatically, rinse, repeat, through the rest of the clustered hosts.
The script takes a parameter for the machine name (else it will default to the local machine) and also the name of the ConfigMgr task sequence to be run. The task sequence must already be advertised to the machine for this script to work because it searches the local WMI repository for the task sequence name and then works backwards to determine a policy ID to trigger. Once the policy ID is found it uses the SMS_Client::TriggerSchedule method to execute the task sequence immediately.
If you need to target a machine but only make the task sequence available on-demand you can set up an advertisement with a mandatory schedule way out in the future, basically something that will never run but the necessary policy objects still get created in the local WMI repository to run on-demand.
See the script comments for the syntax.
Hope you enjoy!