Closed tahershaker closed 6 years ago
Just test it again and i have found that this happens only if you add -EA SilentlyContinue in the connect command, if you did not add -EA option it will error out in the connection initiation
Well - yeah, that's what happens when you suppress the exception with -ErrorAction SilentlyContinue :). If you want it to error, then don't suppress the error :)
Also, you are using Connect-NsxServer incorrectly. Firstly, there is no need to make a separate Connect-ViServer call first. The vCenter connection is handled automatically by Connect-NsxServer. Secondly, if you are using -vCenterServer parameter in connect-nsxserver, then the -username and -password parameters should be sso credentials with access to vCenter and NSX (not 'admin'). If you want to use NSX specific credentials ('admin'), then use the -NsxServer parameter. This is all documented in the Get-Help for Connect-NsxServer. I suggest you have a look at the examples in there.
Hope this helps.
Hi Nick,
Appologies, this is my mistake, should have gone through the Get-Help first before reaching out here. Thanks for your help.
No problem.
Dear All,
I am righting a tool that depends on PowerNsx and when i am connecting to the NSX using the Connect-NsxServer with the -vCenterServer option, the connection will go on even if i give an incorrect NSX Password and thus later if i used any PowerNsx CmdLets it will not retrive anything erroring out iwth 403 error which is logical as the password is in correct.
Shouldnt there be any checks if the primamry connection is successful ?
Please find below sample code: