forked from adbertram/CMClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-CMClientBaselineEvaluation.ps1
95 lines (84 loc) · 3.31 KB
/
Get-CMClientBaselineEvaluation.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<#
.SYNOPSIS
Get the status of Configuration Manager client configuration baselines.
.DESCRIPTION
Get the status of Configuration Manager client configuration baselines.
.NOTES
Created by: Jason Wasser @wasserja
Modified: 5/17/2017 04:05:12 PM
.EXAMPLE
Get-CMClientBaselineEvaluation
ComputerName : SERVER01
BaselineName : SMB1 Disabled
Version : 2
EvaluationStatus : Idle
Compliance : Compliant
LastEvaluationTime : 5/17/2017 7:46:44 PM
.EXAMPLE
Get-CMClientBaselineEvaluation -ComputerName SERVER01,SERVER02
ComputerName : SERVER01
BaselineName : SMB1 Disabled
Version : 2
EvaluationStatus : Idle
Compliance : Compliant
LastEvaluationTime : 5/17/2017 7:46:44 PM
ComputerName : SERVER02
BaselineName : SMB1 Disabled
Version : 2
EvaluationStatus : Idle
Compliance : Compliant
LastEvaluationTime : 5/17/2017 7:46:37 PM
#>
function Get-CMClientBaselineEvaluation
{
[CmdletBinding()]
param (
[Parameter(Mandatory=$false,
ValueFromPipelineByPropertyName=$true,
ValueFromPipeline=$true,
Position=0)]
[string[]]$ComputerName=$env:COMPUTERNAME
)
begin {
$ComplianceHash = [hashtable]@{
"0" = 'Non-Compliant'
"1" = 'Compliant'
"2" = 'Submitted'
"3" = 'Unknown'
"4" = 'Detecting'
"5" = 'Not Evaluated'
}
$EvalHash = [hashtable]@{
"0" = 'Idle'
"1" = 'Evaluated'
"5" = 'Not Evaluated'
}
}
process {
foreach ($Computer in $ComputerName) {
# Get a list of baseline objects assigned to the remote computer
Write-Verbose -Message "Attempting to get Configuration Baselines for $Computer"
$Baselines = Get-WmiObject -ComputerName $Computer -Namespace root\ccm\dcm -Class SMS_DesiredConfiguration
# For each (%) baseline object, call SMS_DesiredConfiguration.TriggerEvaluation, passing in the Name and Version as params
foreach ($Baseline in $Baselines) {
if ($Baseline.LastEvalTime -eq '00000000000000.000000+000') {
$LastEvalTime = 'N/A'
}
else {
$LastEvalTime = $Baseline.ConvertToDateTime($Baseline.LastEvalTime)
}
$BaselineStatusProperties = [ordered]@{
ComputerName = $Baseline.PSComputerName
BaselineName = $Baseline.DisplayName
Version = $Baseline.Version
EvaluationStatus = $EvalHash[$Baseline.Status.tostring()]
Compliance = $ComplianceHash[$Baseline.LastComplianceStatus.tostring()]
LastEvaluationTime = $LastEvalTime
}
$BaselineStatus = New-Object -TypeName pscustomobject -Property $BaselineStatusProperties
$BaselineStatus
}
}
}
end {}
}