Le script ci dessous, récupéré chez un client (merci Pascal!!!) permet de lancer toutes les actions disponibles dans le client SCCM afin de forcer la récupération des stratégies, envoyer l’inventaire logiciel et matériel, etc…
Très très pratique
# DECLARATION DE FONCTIONS Function Get-Actions($actions){ $actions | select Name } Function Execute-Action($actions,$name){ [ARRAY]$actionToPerform = $null if(($name -eq "all") -AND ($actions -ne $null)){ foreach($action in $actions){ $actionToPerform += $action } } else { $actionToPerform += $actions | ?{$_.Name -like $name} } if($actionToPerform -ne $null){ foreach($action in $actionToPerform) { Write-Host (">> Executing : " + ($action.Name)) $action.PerformAction() } } else { Write-Host "Unable to run client action : $name" } } function Get-AllActions ($actions){ Execute-Action $actions "all" } function Get-MachinePolicy ($actions){ Execute-Action $actions "*Machine Policy" } Function Get-UserPolicy ($actions){ Execute-Action $actions "*User Policy" } Function Update-CollectionCycle ($actions){ Execute-Action $actions "*Collection Cycle" } Function Update-MSI ($actions){ Execute-Action $actions "MSI*" } Function Update-WSUS ($actions){ Execute-Action $actions "Software Updates*" } Function Update-Source ($actions){ Execute-Action $actions "Updates Source*" } Function Report-SoftwareMetering ($actions){ Execute-Action $actions "Software Metering*" } Function Execute-Action($actions,$name){ [ARRAY]$actionToPerform = $null if(($name -eq "all") -AND ($actions -ne $null)){ foreach($action in $actions){ $actionToPerform += $action } } else { $actionToPerform += $actions | ?{$_.Name -like $name} } if($actionToPerform -ne $null){ foreach($action in $actionToPerform) { Write-Host (">> Executing : " + ($action.Name)) $action.PerformAction() } } else { Write-Host "Unable to run client action : $name" } } # ----------------------------------------------------- # UPDATE SCCM TO RUN # ----------------------------------------------------- $sms_client = New-Object -COM 'CPApplet.CPAppletMgr' $actions = $sms_client.GetClientActions() Write-host -FORE RED "# -----------------------------------------------------" Write-host -FORE RED ("# UPDATING SCCM CLIENT " + (get-date -uFormat "%Y %H:%M:%S")) Write-host -FORE RED "# -----------------------------------------------------" Write-host -FORE RED " " Get-AllActions $actions