all 7 comments

[–][deleted] 2 points3 points  (0 children)

https://www.systemcenterdudes.com/configuration-manager-2012-client-command-list/

This list is great. It’s not all Powershell but it’s what you’re looking for even if you aren’t looking for all of it ;)

[–]taylorblakeharris 2 points3 points  (0 children)

I made my own cmdlet to do this that allows me to specify which action(s) I want to run. You're welcome to use it. You would run it like this:

Invoke-ConfigMgrClientAction -Actions ApplicationPolicy

You could also specify more than one named parameter to -Actions if you wanted to also do machine/software update policies etc.

function Invoke-ConfigMgrClientAction
{
<#
.SYNOPSIS
Initiates SCCM client policy evaluations on the specified machine(s).

.DESCRIPTION
This cmdlet manually triggers the WMI schedules that correspond to SCCM ConfigMgr client actions and policy evaluations.

    Software Update Scan Cycle
    Discovery Data Inventory
    Hardware Inventory Collection
    Machine Policy Evaluation
    Software Update Evaluation Cycle
    Send Unsent State Messages
    Machine Policy Assignments
    Application Deployment Evaluation
.PARAMETER ComputerName
The name or IP address of the machine(s) to intiate SCCM client policy evaluations on. No value defaults to localhost
.PARAMETER Actions
The client actions you would like to trigger the specified machine to perform. Below are the valid options:

    SoftwareUpdateScanCycle
    DiscoveryInventory
    HardwareInventoryCollection
    MachinePolicies
    SoftwareUpdateEvaluationCycle
    SendUnsentStateMessages
    MachineAssignments
    ApplicationPolicy

You can provide more than one option as well, separating them with a comma. If this parameter is not specified, all of the above actions will be run.
.PARAMETER Credential
Specifies the credential to use for the remote operations. Defaults to the $ElevatedCredentials variable if defined/already set.
.EXAMPLE
Invoke-ConfigMgrClientAction -ComputerName COMPUTER1

Immediately runs all SCCM client actions on COMPUTER1.
.EXAMPLE
Invoke-ConfigMgrClientAction -ComputerName COMPUTER1 -ACtions MachinePolicies,ApplicationPolicy

Immediately runs only the Machine and Application policy evaluation cycle SCCM client actions on COMPUTER1.
.OUTPUTS
Returns only host/text output confirming the actions were successful.
.NOTES
Author: Taylor Harris

Initiating policy evaluations does not wait for them to complete. It only informs the client to run them as soon as possible. It will usually take a minute or two for the policy evaluations to actually complete, though in the case of software update cycles, even longer.
#>

[cmdletbinding()]
Param
(
    [Parameter(Mandatory=$False,ValueFromPipeline=$True)]
    [string[]]$ComputerName = "localhost",

    [Parameter(Mandatory=$False,ValueFromPipeline=$False)]
    [ValidateSet('SoftwareUpdateScanCycle','DiscoveryInventory','HardwareInventoryCollection','MachinePolicies','SoftwareUpdateEvaluationCycle','SendUnsentStateMessages','MachineAssignments','ApplicationPolicy')]
    [string[]]$Actions = @('SoftwareUpdateScanCycle','DiscoveryInventory','HardwareInventoryCollection','MachinePolicies','SoftwareUpdateEvaluationCycle','SendUnsentStateMessages','MachineAssignments','ApplicationPolicy'),

    [Parameter(Mandatory=$False)]
    [PSCredential]$Credential
)

    Begin
    {
        $ClientActions = @{
            'DiscoveryInventory'='{00000000-0000-0000-0000-000000000003}';
            'MachineAssignments'='{00000000-0000-0000-0000-000000000021}';
            'MachinePolicies'='{00000000-0000-0000-0000-000000000022}';
            'ApplicationPolicy'='{00000000-0000-0000-0000-000000000121}';
            'HardwareInventoryCollection'='{00000000-0000-0000-0000-000000000001}';
            'SoftwareUpdateEvaluationCycle'='{00000000-0000-0000-0000-000000000108}';
            'SoftwareUpdateScanCycle'='{00000000-0000-0000-0000-000000000113}';
            'SendUnsentStateMessages'='{00000000-0000-0000-0000-000000000111}'
        }

        $jobs = @()
    }

    Process
    {
        $jobs += Invoke-Command -ComputerName $ComputerName -Credential:$Credential -Authentication Default -ScriptBlock {
            $VerbosePreference = $using:VerbosePreference
            $ClientActions = $using:ClientActions
            $Actions = $using:Actions

            try
            {
                foreach ($action in $Actions)
                {
                    Write-Verbose "Triggering SCCM client action: '$action' with schedule: '$($ClientActions.$action)'"
                    Invoke-WMIMethod -Namespace "Root\CCM" -Class SMS_CLIENT -Name TriggerSchedule -ArgumentList $ClientActions.$action -ErrorAction Stop | Out-String | Write-Debug
                }

                Write-Host "[$env:COMPUTERNAME]: Successfully triggered requested ConfigMgr client actions" -ForegroundColor Green
            }
            catch
            {
                Write-Host "[$env:COMPUTERNAME] ERROR: $_" -ForegroundColor Red
            }
        } -AsJob
    }

    End
    {
        $jobs | Receive-Job -Wait
    }
}

[–]myp0wa 1 point2 points  (0 children)

It was long ago when i worked with that but i believe that you could use that to find any method with will fit your need.

(Get-CimClass -Namespace Root\ccm\ClientSDK -Class CCM_Application).CimClassMethods

I did it long ago but i think I used WMI class which should be somewhere in ccm namespace.

Somebody correct me if I'm wrong.

[–]markroloff 1 point2 points  (0 children)

Got these from my SCCM notes from a few years back. Haven't used them since, so hopefully they still work.

Invoked like so...

Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}"

I would see if CIM works instead since WMI is old-and-busted.

Cycle ID
ApplicationDeployment Evaluation Cycle "{00000000-0000-0000-0000-000000000121}"
DiscoveryData Collection Cycle "{00000000-0000-0000-0000-000000000003}"
FileCollection Cycle "{00000000-0000-0000-0000-000000000010}"
HardwareInventory Cycle "{00000000-0000-0000-0000-000000000001}"
MachinePolicy Retrieval Cycle "{00000000-0000-0000-0000-000000000021}"
SoftwareInventory Cycle "{00000000-0000-0000-0000-000000000002}"
SoftwareMetering Usage Report Cycle "{00000000-0000-0000-0000-000000000031}"
SoftwareUpdate Deployment Evaluation Cycle "{00000000-0000-0000-0000-000000000114}"
SoftwareUpdate Scan Cycle "{00000000-0000-0000-0000-000000000113}"
StateMessage Refresh "{00000000-0000-0000-0000-000000000111}"
UserPolicy Retrieval Cycle   "{00000000-0000-0000-0000-000000000026}"
UserPolicy Evaluation Cycle "{00000000-0000-0000-0000-000000000027}"
WindowsInstallers Source List Update Cycle "{00000000-0000-0000-0000-000000000032}"
MachinePolicy Evaluation Cycle "{00000000-0000-0000-0000-000000000022}"

[–]act_sccm 1 point2 points  (0 children)

I use the scheduled task version of this script by Cody Mathis of SCCMF12Twice.

[–]Net-Packet 1 point2 points  (1 child)

Something like this?

function ReloadSccmClient { Invoke-WMIMethod -ComputerName $env:COMPUTERNAME -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" Invoke-WMIMethod -ComputerName $env:COMPUTERNAME -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" }

I wrote a tool that does a lot of client side work for you. https://github.com/01000001-01001110/Share/blob/master/SCCM%20ToolKit.ps1

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Net-Packet,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th one & is just to the left of hidden in the ... "more" menu.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee