简体   繁体   中英

Connect-NsxServer: Response status code does not indicate success: 403 (Forbidden)

On running following command on Ubuntu 18 with PowerShell installed

PS /data/git> Connect-NsxServer -Server $NSXServer -Protocol https -User $User -Password $Password -IgnoreInvalidCertificate:$true -V

I am getting

Connect-NsxServer: Response status code does not indicate success: 403 (Forbidden).

I have also tried the following earlier:

PS /data/git> Connect-NsxServer -Server 10.241.4.197 -Protocol https -User administrator@vsphere.local -Password SepU^BN54QEsk^3 -V

VERBOSE: 'IgnoreInvalidCertificate' not specified. Trying to retrieve and use VMware.Powercli 'InvalidCertificateAction' setting.

VERBOSE: InvalidCertificateAction: Ignore

Previously It was working when I was using Ubuntu 16 which is no longer supported by PowerShell as per their site.
https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.3

I was expecting to connect NSXServer but not connected.

Use Set-PowerCLIConfiguration with its -InvalidCertificateAction parameter set to a Ignore before running the Connect-NsxServer and omit its -IgnoreInvalidCertificate parameter.

PowerShell

$pass = Read-Host "Enter Nsx Server password" -AsSecureString;
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass)
$pass = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false;
Connect-NsxServer -Server 10.241.4.197 -Protocol https -User administrator@vsphere.local -Password $pass;

Supporting Resource

  • Set-PowerCLIConfiguration

    InvalidCertificateAction :

    Ignore - the cmdlet will establish the connection without taking into account that the certificate is invalid.

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