Hello,
On our new infra NUTANIX AHV, when I try to connect with Powershell I've this error :
PS > $PrismIP = "<Prism ip>"
PS > $userName = "<AccountUser>"
PS > $password = ConvertTo-SecureString -String "<ComPlexE%Pass@ord>" -AsPlainText -Force
PS > Disconnect-NTNXCluster *
PS > $connection = Connect-NutanixCluster -Server $PrismIP -UserName $username -Password $password -AcceptInvalidSSLCerts -ForcedConnection
Connect-NutanixCluster : The remote server returned an error: (401) Unauthorized.
At line:1 char:15
+ ... onnection = Connect-NutanixCluster -Server $PrismIP -UserName $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Nutanix.Prism.Common.NutanixCluster:NutanixCluster) tConnect-NutanixCluster], WebException
+ FullyQualifiedErrorId : The username or password you entered is incorrect. Please try again.
,Nutanix.Prism.Common.NutanixCluster
When I try a Invoke-WebRequest command, same error :
PS > $cred = Get-Credential
PS > Invoke-WebRequest https://<Prism ip>:9440/PrismGateway/services/rest/v1/cluster -Credential $cred
Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.
At line:1 char:1
+ Invoke-WebRequest https://<Prism ip>:9440/PrismGateway/services/rest ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) oInvoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
But if I use this method, It's work :
PS > $user='<AccountUser>'
PS > $pass='<ComPlexE%Pass@ord>'
PS > $pair = "$($user):$($pass)"
PS >
PS > $encodedCreds = :System.Convert]::ToBase64String(gSystem.Text.Encoding]::ASCII.GetBytes($pair))
PS > $basicAuthValue = "Basic $encodedCreds"
PS > $Headers = @{ Authorization = $basicAuthValue }
PS >
PS > Invoke-WebRequest -Uri 'https://<Prism ip>:9440/PrismGateway/services/rest/v1/cluster' -Headers $Headers
StatusCode : 200
StatusDescription : OK
On a CentOS serveur if I use this command It's work too :
# curl -k -u <AccountUser>:<ComPlexE%Pass@ord> -X GET --header 'Accept: application/json' https://<Prism ip>:9440/PrismGateway/services/rest/v1/cluster
{"id":"<uuid>","uuid":"<uuid>","clusterIncarnationId":1648047258399236,"clusterUuid":"<uuid>","name":"<Cluster_Name>",................
So if apparently I use a non secure password I can connect, but when password is "secure" (ConvertTo-SecureString / Get-Credential) it does not work.
Do you know what parameter I need to change on AHV/PRISM to allow connection ?
Version :
LCM : 2.4.5.2
AOS : 5.20.4 LTS
NCC : 4.6.0
Foundation : 5.2.1-75e62260
Hypervisor : el7.nutanix.20201105.2286
Thanks