Private/SCCMDeployments/_InvokeSCCMRestMethodSTT.ps1
function _InvokeSCCMRestMethodSTT { # This mostly exists to try and ease error handling since it's not nice within Powershell when calling APIs. param ( [Parameter()] [ValidateSet('Get')] $Method = 'Get', [Parameter(Mandatory = $true)] $Uri ) $params = @{ Method = $Method Uri = $Uri UseDefaultCredentials = $true } try { $Data = Invoke-RestMethod @params } # catch [System.Net.WebException] { # throw ($_.ErrorDetails.Message | ConvertFrom-Json).Error # } catch { throw $_ } # No errors, present data return $Data } |