Why am I getting the error with this code? The term 'elseif' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
# Check Vault login for Tech profile
function Ask-Creds {
param(
[ValidateNotNull()]
$Credential = (Get-credential -message 'Please enter Technician`s login & password for Terminal registration:')
)
$vault="3.2.1.1:8500"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Credential))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{Authorization = $basicAuthValue}
$rawcontent=(Invoke-WebRequest -Uri $vault -Headers $Headers).StatusCode
echo "$rawcontent"
}
$result = Ask-Creds
if ( $result -contains '200' ) { Write-Host "Technician is authenticated!" }
ElseIf ( $result -contains '400' ) {Write-Host "Bad credentials!" | Ask-Creds }
ElseIf ( $result -contains '000' ) {Write-Host "Connection failed!" | exit 1 }
ElseIf : The term 'ElseIf' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ElseIf ( $result -contains '400' )
+ ~~~~~~
Aucun commentaire:
Enregistrer un commentaire