简体   繁体   中英

Getting an error with Connect-NsxServer with powershell PowerNSX module

after running this command

$cred = get-credential
Connect-NsxServer -vCenterServer MyVsphereServer -Credential $cred

I get this error

Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Response Body: 
At C:\Program Files\WindowsPowerShell\Modules\PowerNSX\3.0.1174\PowerNSX.psm1:4939 char:13
+             Throw "Connection to NSX server $NsxServer failed : $_"
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Connection to N...Response Body: :String) [], RuntimeException
    + FullyQualifiedErrorId : Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Respons 
   e Body: 

I see this in the error, but have never set this before either

The variable '$defaultNSXConnection' cannot be retrieved because it has not been set.

The PowerNSX module comment says:

 Invoke-NsxWebRequest uses either a specified connection object as returned
    by Connect-NsxServer, or the $DefaultNsxConnection global variable if
    defined to construct a REST api call to the NSX API.

My account permissions can't be the issue. I can log into the NSX gui and have enterprise admin creds. I can also successfully log into Vsphere with powercli module and run cmdlets against it. It's specifically when I try to connect to NSX that I get an error. Lost at this point. Not sure why it won't work. Tried by IP and FQDN. the -vcenterserver parameter is prefered according to their documenation, and I do see Green text response directing to the correct nsx manager IP address. Everything looks right, but clearly something isn't.

powernsx apparently REQUIRES you to use the administrator@vsphere.local account to use it, regardless if your other admin account can make any API call supported by NSX with native API calls.

Didn't see that in the powernsx documentation. If it's not just an oversite on my part, that really should be front and center in their docs.

We have MS AD authenticated accounts that we use with vSphere. I use PowerNSX with my own credential and no, I do not have to use administrator@vsphere.local. The only way I have success is if I am careful to put the domain of the account in all-caps, Kerberos style. When I give the credential, the ONLY format that works for me is "username@MY.DOMAIN.COM" it is extremely case sensitive. vSphere 6.7, NSX 6.4.8, PowerNSX 3.0.1174

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM