APICalls/Invoke-NetBoxRestMethod.ps1
function Invoke-NetBoxRestMethod { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$APICall, [Parameter(Mandatory = $true)] [ValidateSet('Get', 'Post', 'Delete', 'Patch')] [string]$Method, [switch]$ShowQuery ) if (!$Connection) { $Connection = _NewNetBoxConnection } # There must be a trailing slash to successfully query! $QueryURL = "$($Connection.BaseURL)/$($APICall)" $InvokeSplat = @{ Method = $Method Uri = $QueryURL Headers = $Connection.Header } if ($ShowQuery) { Write-Output $InvokeSplat } else { Invoke-RestMethod @InvokeSplat } } |