Authentication fails with "Invalid username or password".
New-OauthSecurityContext cmdlet is needed to login to the ADFS server and get an OAuth token. Then, the New-VISamlSecurityContext cmdlet is needed to translate the OAuth token to a SAML token. Once the SAML token is generated, Connect-VIServer can authenticate the domain user with the SAML token.1) Validate if the domain users are able to login to vCenter UI via MFA.
2) Add a native application for powercli within the vCenter’s application group in the ADFS server.
To do this, double-click on the vCenter’s app group -> Add Application -> Select Native Application.
In the “Add a new native application” dialogue box, specify the name as powercli-native, copy and save the client identifier, add the redirection URL as http://localhost:8844/auth and click finish.
3) In vCenter’s application group, Select the Web API -> Edit
Navigate to the Identifiers tab -> Add the copied client identifier from the native application creation from step 2 under the Relying party Identifiers tab.
Navigate to Client Permissions tab -> Add -> powercli-native.
Ensure powercli-native is selected under client permissions and check both allatclaims and openid.
Apply and finish.
4) To connect via PowerCLI, save the below script, modify it as per the environment, and execute it.
$VCenterServer = 'vCenter_FQDN'
$TokenEndpointURL = 'https://ADFS_FQDN/adfs/oauth2/token/'
$AuthEndpointURL = 'https://ADFS_FQDN/adfs/oauth2/authorize/'
$RedirectURL = 'http://localhost:8844/auth'
$ClientID = 'Enter powercli-native client-ID here'
$OAuth = $null
$Saml = $null
$Conn = $null
if ( !$OAuth ) { $OAuth = New-OAuthSecurityContext -TokenEndpointUrl $TokenEndpointURL -AuthorizationEndpointUrl $AuthEndpointURL -RedirectUrl $RedirectURL -ClientId $ClientID }
if ( !$Saml ) { $Saml = New-VISamlSecurityContext -VCenterServer $VCenterServer -OAuthSecurityContext $OAuth -IgnoreSslValidationErrors }
if ( !$Conn ) { $Conn = Connect-VIServer -Server $VCenterServer -SamlSecurityContext $Saml }
Reference documents:
Note: A similar behavior is also observed in tools such as Dell RV Tools. For further assistance, please contact the respective vendor's support team.