ConfigMgr Client Policy Settings – Get-CMclientpolicysettings
Here’s a function i wrote recently to retrieve the ConfigMgr Client Policy settings. To use the function you must have the System Center Configuration Manager Cmdlet library installed.
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 |
Function Get-CMclientpolicysettings { <# .Synopsis Get-CMclientpolicysettings .DESCRIPTION Get-CMclientpolicysettings retrieves Configuration Manager client agent policy settings. .PARAMETER Name The ConfigMgr Agent Policy Name .EXAMPLE Get-CMclientpolicysettings .EXAMPLE Get-CMclientpolicysettings -Name "Workstation Settings" .NOTES version 1.1, 21.02.2017, Alex Verboon #> [CmdletBinding()] Param( # ConfigMgr Agent Policy Name [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, Position=0)] $Name ) Begin{ Write-verbose "Retrieving Policies" if ($PSBoundParameters.ContainsKey("Name")) { $cmpolicies = Get-CMClientSetting | Select-Object Name | Where-Object {$_.Name -eq "$Name"} } Else { $cmpolicies = Get-CMClientSetting | Select-Object Name } } Process{ $Results = @() foreach ($policy in $cmpolicies ) { write-verbose "$($Policy.name)" $xsettings = [Enum]::GetNames( [Microsoft.ConfigurationManagement.Cmdlets.ClientSettings.Commands.SettingType]) foreach ($setting in $xsettings) { Write-verbose $setting $configuration = Get-CMClientSetting -Setting $setting -Name $Pol.name ForEach ($config in $configuration.GetEnumerator()) { write-verbose $config.Key $data = [ordered] @{ PolicyName = $policy.Name Setting = $setting ConfigurationName = $config.Key ConfigurationValue = $config.Value } $Results += (New-Object -TypeName psobject -Property $data) } } } } End{Write-Output $Results} } |