Created
October 10, 2019 19:18
-
-
Save Robert-LTH/80aa55e8036e35e0ca83bd18a3c7d870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$BaselineName | |
) | |
$ErrorActionPreference = "Stop" | |
try { | |
$Params = @{ | |
Namespace = 'ROOT\ccm\Policy\Machine\ActualConfig' | |
ClassName = 'CCM_DCMCIAssignment' | |
Property = 'AssignmentID','AssignmentName' | |
} | |
if ($BaselineName -ne 'All') { | |
$Params.Add('Filter',"AssignmentName LIKE '$($BaselineName)_%'") | |
} | |
$Assignment = Get-CimInstance @Params | Select-Object -Property AssignmentID,AssignmentName | |
if (-not $Assignment) { | |
Write-Host "No baseline with name '$BaselineName' was found." | |
return | |
} | |
$Assignment | ForEach-Object { | |
$Result = Invoke-CimMethod -Namespace root\ccm -ClassName SMS_Client -MethodName 'TriggerSchedule' -Arguments @{ sScheduleId = $_.AssignmentID } | |
if ($Result) { | |
Write-Host "Triggered evaluation of '$(($_.AssignmentName -split '_')[0])'" | |
} | |
else { | |
Write-Host "Failed to trigger evaluation of '$(($_.AssignmentName -split '_')[0])'" | |
} | |
} | |
} catch { | |
Write-Host "Something went wrong: $_" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment