Correct brace formatting

This commit is contained in:
Ben Claussen 2021-07-22 10:28:22 -04:00
parent 989c5eaac2
commit 06d758d7b3
3 changed files with 6 additions and 12 deletions

View file

@ -95,13 +95,11 @@ function InvokeNetboxRequest {
if ($Raw) { if ($Raw) {
Write-Verbose "Returning raw result by choice" Write-Verbose "Returning raw result by choice"
return $result return $result
} } else {
else {
if ($result.psobject.Properties.Name.Contains('results')) { if ($result.psobject.Properties.Name.Contains('results')) {
Write-Verbose "Found Results property on data, returning results directly" Write-Verbose "Found Results property on data, returning results directly"
return $result.Results return $result.Results
} } else {
else {
Write-Verbose "Did NOT find results property on data, returning raw result" Write-Verbose "Did NOT find results property on data, returning raw result"
return $result return $result
} }

View file

@ -58,8 +58,7 @@
if (-not $Credential) { if (-not $Credential) {
try { try {
$Credential = Get-NetboxCredential -ErrorAction Stop $Credential = Get-NetboxCredential -ErrorAction Stop
} } catch {
catch {
# Credentials are not set... Try to obtain from the user # Credentials are not set... Try to obtain from the user
if (-not ($Credential = Get-Credential -UserName 'username-not-applicable' -Message "Enter token for Netbox")) { if (-not ($Credential = Get-Credential -UserName 'username-not-applicable' -Message "Enter token for Netbox")) {
throw "Token is necessary to connect to a Netbox API." throw "Token is necessary to connect to a Netbox API."
@ -106,14 +105,12 @@
try { try {
Write-Verbose "Verifying API connectivity..." Write-Verbose "Verifying API connectivity..."
$null = VerifyAPIConnectivity $null = VerifyAPIConnectivity
} } catch {
catch {
Write-Verbose "Failed to connect. Generating error" Write-Verbose "Failed to connect. Generating error"
Write-Verbose $_.Exception.Message Write-Verbose $_.Exception.Message
if (($_.Exception.Response) -and ($_.Exception.Response.StatusCode -eq 403)) { if (($_.Exception.Response) -and ($_.Exception.Response.StatusCode -eq 403)) {
throw "Invalid token" throw "Invalid token"
} } else {
else {
throw $_ throw $_
} }
} }

View file

@ -2,8 +2,7 @@ function Set-NetboxInvokeParams {
[CmdletBinding(ConfirmImpact = 'Low', [CmdletBinding(ConfirmImpact = 'Low',
SupportsShouldProcess = $true)] SupportsShouldProcess = $true)]
[OutputType([string])] [OutputType([string])]
param param(
(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[array]$InvokeParams [array]$InvokeParams
) )