#Replace with name of Baseline $BLString = "BaselineName" #Replace with path to input csv (with field containing machines named Name) $file = "c:\temp\input.csv" $CountProcessed = 0 $rows = (Import-Csv $file).count Import-Csv $file | ForEach-Object { $ComputerName = $_."Name" $CountProcessed++ $percent = (($CountProcessed/$rows)*100) Cls Write-host "$('{0:N2}' -f $percent)% complete" $Online = Test-Connection -Computername $ComputerName -BufferSize 16 -Count 1 -Quiet If ($Online -eq "True") { $BLname = Get-WmiObject -ComputerName $ComputerName -Namespace root\ccm\dcm -Class SMS_DesiredConfiguration | Where-Object {$_.DisplayName -match $BLString} | Select-Object -ExpandProperty Name $version = Get-WmiObject -ComputerName $ComputerName -Namespace root\ccm\dcm -Class SMS_DesiredConfiguration | Where-Object {$_.DisplayName -match $BLString} | Select-Object -ExpandProperty Version $MC = [WmiClass]"\\$ComputerName\root\ccm\dcm:SMS_DesiredConfiguration" $Method = "TriggerEvaluation" $InParams = $mc.psbase.GetMethodParameters($Method) $InParams.IsEnforced = $true $InParams.IsMachineTarget = $false $InParams.Name = "$BLname" $InParams.Version = "$version" $inparams.PSBase.properties | select Name,Value | Out-Null $R = $MC.InvokeMethod($Method, $InParams, $null) $R | Out-Null} } Write-Host "Processed" $CountProcessed "of" $rows
The input file should be formatted as follows:
Name Machine 1 Machine 2 Machine 3 etc..
Original post from http://richardchesterton.com/force-configmgr-compliance-baseline-evaluation-on-multiple-machines-with-powershell/
No comments:
Post a Comment