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 {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Connects to the Netbox API and ensures Credential work properly
|
||||
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
if (-not $Credential) {
|
||||
try {
|
||||
$Credential = Get-NetboxCredential -ErrorAction Stop
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
# Credentials are not set... Try to obtain from the user
|
||||
if (-not ($Credential = Get-Credential -UserName 'username-not-applicable' -Message "Enter token for Netbox")) {
|
||||
throw "Token is necessary to connect to a Netbox API."
|
||||
|
|
@ -85,12 +86,14 @@
|
|||
try {
|
||||
Write-Verbose "Verifying API connectivity..."
|
||||
$null = VerifyAPIConnectivity
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
Write-Verbose "Failed to connect. Generating error"
|
||||
Write-Verbose $_.Exception.Message
|
||||
if (($_.Exception.Response) -and ($_.Exception.Response.StatusCode -eq 403)) {
|
||||
throw "Invalid token"
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw $_
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue