Private/SCCMDeployments/_GetSCCMInformationQuerySTT.ps1
function _GetSCCMInformationQuerySTT { <# .SYNOPSIS This is a way to call a number of connectors with one function. .DESCRIPTION This function will only get the entirety of one class. It doesn't get a specific item in the results and it can't go deeper. Be careful with this function. If you provide a connector with a lot of data to return, it will cause the database to stop responding until the query completes. .EXAMPLE _GetSCCMInformationQuery -Route wmi -Connector 'SMS_Role' This gets the roles on the SCCM server. .EXAMPLE _GetSCCMInformationQuery -Route wmi -Connector SMS_R_System -FilterField NetbiosName -FilterString $Env:ComputerName This gets the system information for the host running the command #> param ( [Parameter(Mandatory = $true)] [ValidateSet('wmi', 'v1.0')] [string]$Route, [Parameter(Mandatory = $true)] [string]$Connector, [Parameter(HelpMessage = 'This runs a contains unless you specify -ExactMatch.', Mandatory = $false, ParameterSetName = 'Filter')] [string]$FilterField, [Parameter(Mandatory = $false, ParameterSetName = 'Filter')] [string]$FilterString, [Parameter(ParameterSetName = 'Filter')] [switch]$ExactMatch, [Parameter()] [string]$SCCMServer = 'SVP109APP.internal.sccourts.org', [Parameter()] [switch]$ShowQuery ) begin { $Connection = "https://$SCCMServer/AdminService" if ($FilterField) { switch ($ExactMatch) { $true { $Connector = "$($Connector)?`$filter=$FilterField eq '$FilterString'" } $false { $Connector = "$($Connector)?`$filter=contains($FilterField,'$FilterString') eq true" } } } $URL = "$Connection/$Route/$Connector" } process { if ($ShowQuery) { Write-Output $URL } else { try { $Data = _InvokeSCCMRestMethodSTT -Uri $URL return $Data.value | Select-Object -Property * -ExcludeProperty _*, `@odata* } catch { throw } } } } |