Invoke-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
<#
.Synopsis
   Initiate the evaluation of Configuration Manager client configuration baselines.
 
.DESCRIPTION
   Initiate the evaluation of Configuration Manager client configuration baselines.
 
.NOTES
   Created by: Jason Wasser @wasserja
   Modified: 5/17/2017 04:09:20 PM
 
.EXAMPLE
Invoke-CMClientBaselineEvaluation
 
__GENUS : 1
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH : __PARAMETERS
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER : SERVER01
__NAMESPACE : ROOT\ccm\dcm
__PATH : \\SERVER01\ROOT\ccm\dcm:__PARAMETERS
JobId : {70CC8CE2-1349-4B2A-9D6C-030DE174D269}
ReturnValue : 0
PSComputerName : SERVER01
 
.EXAMPLE
Invoke-CMClientBaselineEvaluation -ComputerName SERVER01,SERVER02
 
__GENUS : 1
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH : __PARAMETERS
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER : SERVER01
__NAMESPACE : ROOT\ccm\dcm
__PATH : \\SERVER01\ROOT\ccm\dcm:__PARAMETERS
JobId : {70CC8CE2-1349-4B2A-9D6C-030DE174D269}
ReturnValue : 0
PSComputerName : SERVER01
 
__GENUS : 1
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH : __PARAMETERS
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER : SERVER02
__NAMESPACE : ROOT\ccm\dcm
__PATH : \\SERVER02\ROOT\ccm\dcm:__PARAMETERS
JobId : {1D92D42D-B1B4-4256-B8AE-24F7CC382578}
ReturnValue : 0
PSComputerName : SERVER02
 
#>

function Invoke-CMClientBaselineEvaluation
{
    [CmdletBinding()]
    param (        
        [Parameter(Mandatory=$false,
                   ValueFromPipelineByPropertyName=$true,
                   ValueFromPipeline=$true,
                   Position=0)]
        [string[]]$ComputerName=$env:COMPUTERNAME
    )
    begin {}
    process {
        foreach ($Computer in $ComputerName) {
            # Get a list of baseline objects assigned to the remote 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
            $Baselines | foreach { ([wmiclass]"\\$Computer\root\ccm\dcm:SMS_DesiredConfiguration").TriggerEvaluation($_.Name, $_.Version) }
            }
        }
    end {}
    
}