This commit is contained in:
Wago Louage 2024-08-28 14:52:27 +00:00 committed by GitHub
commit 2fef45b0e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 59 additions and 48 deletions

View file

@ -14,6 +14,8 @@ function Set-NetboxIPAMAddress {
[uint64]$Tenant, [uint64]$Tenant,
[uint64][]$Tags,
[uint64]$VRF, [uint64]$VRF,
[object]$Role, [object]$Role,

View file

@ -271,7 +271,7 @@ function Add-NetboxVirtualMachineInterface {
function BuildNewURI { function BuildNewURI {
<# <#
.SYNOPSIS .SYNOPSIS
Create a new URI for Netbox Create a new URI for Netbox
@ -301,7 +301,7 @@ function BuildNewURI {
.NOTES .NOTES
Additional information about the function. Additional information about the function.
#> #>
[CmdletBinding()] [CmdletBinding()]
[OutputType([System.UriBuilder])] [OutputType([System.UriBuilder])]
@ -333,16 +333,25 @@ function BuildNewURI {
Write-Verbose " URIPath: $($uriBuilder.Path)" Write-Verbose " URIPath: $($uriBuilder.Path)"
if ($parameters) { if ($Parameters) {
# Loop through the parameters and use the HttpUtility to create a Query string # Loop through the parameters and use the HttpUtility to create a Query string
[System.Collections.Specialized.NameValueCollection]$URIParams = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) [System.Collections.Specialized.NameValueCollection]$URIParams = [System.Web.HttpUtility]::ParseQueryString($uriBuilder.Query)
foreach ($param in $Parameters.GetEnumerator()) { foreach ($param in $Parameters.GetEnumerator()) {
Write-Verbose " Adding URI parameter $($param.Key):$($param.Value)" Write-Verbose " Adding URI parameter $($param.Key):$($param.Value)"
if ($param.Key -eq 'q') {
# Append the query string directly
$uriBuilder.Query = $uriBuilder.Query.TrimStart('?') + '&' + $param.Value
}
else {
$URIParams[$param.Key] = $param.Value $URIParams[$param.Key] = $param.Value
} }
}
$uriBuilder.Query = $URIParams.ToString() # Combine the existing query with new parameters
$existingQuery = $uriBuilder.Query.TrimStart('?')
$newQuery = $URIParams.ToString()
$uriBuilder.Query = ($existingQuery + '&' + $newQuery).Trim('&')
} }
Write-Verbose " Completed building URIBuilder" Write-Verbose " Completed building URIBuilder"