Getting an error with Connect-NsxServer with powershell PowerNSX module

我是研究僧i 提交于 2020-03-03 07:41:06

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/60009744/getting-an-error-with-connect-nsxserver-with-powershell-powernsx-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!