mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
Connect(Setup): Fix indent (using Visual code Formatter)
This commit is contained in:
parent
1f89363cbd
commit
b164ffe0b4
1 changed files with 32 additions and 29 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
function Connect-NetboxAPI {
|
function Connect-NetboxAPI {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Connects to the Netbox API and ensures Credential work properly
|
Connects to the Netbox API and ensures Credential work properly
|
||||||
|
|
||||||
|
|
@ -55,7 +55,8 @@
|
||||||
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."
|
||||||
|
|
@ -85,12 +86,14 @@
|
||||||
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 $_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue