Functions/Get-IAFilter.ps1
Function Get-IAFilter { <# .SYNOPSIS Is used to query for different filters. .DESCRIPTION This function is used to get different filters that are used in Insight Analytics. Filters include Collections, Packages, TaskSequences and everything else that is used to configure and set-up Widgets. .EXAMPLE Get-IAFilter -All #> [CmdletBinding(DefaultParameterSetName='Name')] Param( [Parameter(Mandatory = $true, ParameterSetName='All')] [Switch] $All ) DynamicParam { $Bucket = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameterDictionary $AttributeList = New-Object -TypeName System.Collections.ObjectModel.Collection[System.Attribute] $Values = (Invoke-IAQuery -QueryUrl 'configmgr/' -Method Get).Value.Name $AttribValidateSet = New-Object System.Management.Automation.ValidateSetAttribute($Values) $AttributeList.Add($AttribValidateSet) $AttribParameter = New-Object System.Management.Automation.ParameterAttribute $AttribParameter.Mandatory = $true $AttribParameter.ParameterSetName = 'Name' $AttribParameter.Position = 0 $AttributeList.Add($AttribParameter) $ParameterName = 'Name' $Parameter = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameter($ParameterName,[String], $AttributeList) $Bucket.Add($ParameterName, $Parameter) $Bucket } End { Foreach ($key in $PSBoundParameters.Keys) { if ($MyInvocation.MyCommand.Parameters.$key.isDynamic) { Set-Variable -Name $key -Value $PSBoundParameters.$key } } $Uri = "configmgr/" if($All){} elseif($Name){ $Uri += "$Name" } $response = Invoke-IAQuery -QueryUrl $Uri -Method Get if ($null -eq $response.value) { return $null } if($All){ return $response.Value | Select-Object -ExpandProperty Name } else{ return $response.value } } } |