So, finally was able to get back to this script but, I'm still having issues trying to capture the error and how to deal with it. Yea, I know I'm a rookie at PS.
It seems that since the PS script is making a request to an external source, I can't or, am having a problem capturing that error. So, as in my first post, if I run this line:
Connect-NaController $Filer -credential (Get-Credential) -HTTPS And put in bad or wrong credentials, I get the following error.
Connect-NaController : Incorrect credentials for NaFiler001.
At C:\Users\UserName\Downloads\PowerShell Stuff\Scripts\Tests\NA_Logon_Test.ps1:18 char:2
+ Connect-NaController $Filer -credential (Get-Credential) -HTTPS
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: nafiler001:NaController) [Connect-NaController], NaAuthException
+ FullyQualifiedErrorId : HttpConnectionFailed,DataONTAP.PowerShell.SDK.ConnectNaController
I even tried this but, even with this next example, I get the exact error as above in Italic.
try
{
Connect-NaController $Filer -credential (Get-Credential) -HTTPS
}
catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Host "Authentication failed due to $ErrorMessage. The error was $FailedItem"
Break
}
I realize I'm missing something here but, hopefully someone can get me down the correct path.
Thanks,
Joe