【发布时间】:2020-01-31 18:55:23
【问题描述】:
运行此命令后
$cred = get-credential
Connect-NsxServer -vCenterServer MyVsphereServer -Credential $cred
我收到此错误
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:
我在错误中看到了这个,但之前也从未设置过这个
The variable '$defaultNSXConnection' cannot be retrieved because it has not been set.
PowerNSX 模块评论说:
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.
我的帐户权限不是问题。我可以登录 NSX gui 并拥有企业管理员凭据。我还可以使用 powercli 模块成功登录 Vsphere 并针对它运行 cmdlet。特别是当我尝试连接到 NSX 时出现错误。迷失在这一点上。不知道为什么它不起作用。通过 IP 和 FQDN 尝试。根据他们的文档,首选 -vcenterserver 参数,我确实看到绿色文本响应指向正确的 nsx 管理器 IP 地址。一切看起来都对,但显然有些不对。
【问题讨论】:
-
这可能会帮助您到达那里,Creating a User for NSX CLI and assigning API。如果您可以访问 UI,并不一定意味着您也可以访问 API。检查并确保该帐户也具有 API 访问权限。
标签: powershell vsphere powercli