-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathScript-InvokeBaseline.ps1
42 lines (33 loc) · 1.09 KB
/
Script-InvokeBaseline.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
param(
[string]$BLName
)
$BLQuery = [string]::Format("SELECT * FROM SMS_DesiredConfiguration WHERE DisplayName = '{0}'", $BLName)
$getBaselineSplat = @{
Namespace = 'root\ccm\dcm'
ErrorAction = 'Stop'
Query = $BLQuery
}
$invokeBaselineEvalSplat = @{
Namespace = 'root\ccm\dcm'
ClassName = 'SMS_DesiredConfiguration'
ErrorAction = 'Stop'
Name = 'TriggerEvaluation'
}
$PropertyOptions = 'IsEnforced', 'IsMachineTarget', 'Name', 'PolicyType', 'Version'
$BL = Get-CimInstance @getBaselineSplat
$ArgumentList = @{ }
foreach ($Property in $PropertyOptions) {
$PropExist = Get-Member -InputObject $BL -MemberType Properties -Name $Property -ErrorAction SilentlyContinue
switch ($PropExist) {
$null {
continue
}
default {
$TypeString = ($PropExist.Definition.Split(' '))[0]
$Type = [scriptblock]::Create("[$TypeString]")
$ArgumentList[$Property] = $BL.$Property -as (. $Type)
}
}
}
$invokeBaselineEvalSplat['Arguments'] = $ArgumentList
Invoke-CimMethod @invokeBaselineEvalSplat