Private/WhatsUpGold/_InvokeSTTWUGRestMethod.ps1
function _InvokeSTTWUGRestMethod { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$APICall, [Parameter(Mandatory=$true)] [ValidateSet('Get', 'Post', 'Delete', 'Patch')] [string]$Method, [switch]$ShowQuery ) if (!$Connection) { $WUGServerHostname = $STTSettings.WhatsUpGoldSettings.WUGServerHostname $WUGServerPort = $STTSettings.WhatsUpGoldSettings.WUGServerPort $Connection = _GetSTTWUGAccessToken -ServerHostname $WUGServerHostname -Port $WUGServerPort } $QueryURL = "$($Connection.BaseURL)/$($APICall)" $InvokeSplat = @{ Method = $Method Uri = $QueryURL Header = $Connection.Header } if ($ShowQuery) { Write-Output $InvokeSplat.Uri } else { Invoke-RestMethod @InvokeSplat } } |