Force Evaluation of a Baseline

This script will trigger a specified baseline to evaluate on a computer using the run script function in SCCM. If no baseline is specified all baselines on the computer will be evaluated.

param (
    [String][Parameter(Mandatory = $False, Position = 1)] $BLName
)

$ComputerName = $env:COMPUTERNAME

If ($BLName -eq $Null) {
    $Baselines = Get-WmiObject -ComputerName $ComputerName -Namespace root\ccm\dcm -Class SMS_DesiredConfiguration
}
Else {
    $Baselines = Get-WmiObject -ComputerName $ComputerName -Namespace root\ccm\dcm -Class SMS_DesiredConfiguration | Where-Object { $_.DisplayName -like $BLName }
}
 
$Baselines | % {
 
 ([wmiclass]"\\$ComputerName\root\ccm\dcm:SMS_DesiredConfiguration").TriggerEvaluation($_.Name, $_.Version) 
 
}