vCenter Server 8.0 allows administrators to federate identity with Entra ID (formerly Azure AD), enabling seamless SSO and MFA. However, integrating this setup with automation tools like PowerCLI introduces a few challenges. This guide walks through enabling and using PowerCLI with federated logins.
After enabling this federated identity feature, a few additional considerations are required when connecting using PowerCLI. In most Entra ID environments multifactor authentication is enforced, for example via conditional access policy. As such, attempting to login with just a username and password will fail. Here is a sample error response:
> Connect-VIServer vc3.example.com -User h163-user2@lab.enterpriseadmins.org -Password VMware1!
Connect-VIServer : 4/29/2025 6:29:26 PM Connect-VIServer Cannot complete login due to an incorrect user name or password.
At line:1 char:1
+ Connect-VIServer vc3.example.com -User h163-user2@lab.enterpriseadmin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-VIServer], InvalidLogin
+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_SoapException,VMware.VimAutomation.ViCore.Cmdlets.Command
s.ConnectVIServer
The good news is we can still allow clients/end users to login via their federated identities with a little setup.
Administrator / Grant access to PowerCLI User
As an administrator, we’ll create a new OAuth2 client. We will share this client details with the client who wishes to use PowerCLI. In the codeblock below we’ll use splatting to make the code a bit more readable.
$newOAuthArguments = @{
ClientID = 'h366-powercli-native-Brian'
Name = 'h366-PowerCLI Client2'
Scope = @("openid", "user", "group")
GrantTypes = @("authorization_code", "refresh_token")
RedirectUris = @("http://localhost:8844/authcode")
PkceEnforced = $true
AccessTokenTimeToLiveMinutes = 30
RefreshTokenTimeToLiveMinutes = 43200
RefreshTokenIdleTimeToLiveMinutes = 28800
}
$newClient = New-VIOAuth2Client @newOAuthArguments
In the above example, we assigned the output of New-VIOAuth2Client
to a variable and did not specify a Secret
parameter. With this configuration, a secret will be automatically generated, but that value is not returned in the default output of the cmdlet. We’ll use $newClient.secret
to view the new secret of: s1A9RxZ0FbBEGoMplD0HcbQITBODtX85
. We’ll need to share the ClientID and Secret value with the person wishing to authenticate.
Client / PowerCLI User
In the step above, our administrator created a New-VIOAuth2Client
for us and shared the following details:
- ClientID =
h366-powercli-native-Brian
- Secret =
s1A9RxZ0FbBEGoMplD0HcbQITBODtX85
We’ll now use those values to login to our vCenter Server using PowerCLI.
$newOAuthArguments = @{
TokenEndpointUrl = 'https://test-vcsa-03.lab.enterpriseadmins.org/acs/t/CUSTOMER/token'
AuthorizationEndpointUrl = 'https://test-vcsa-03.lab.enterpriseadmins.org/acs/t/CUSTOMER/authorize'
RedirectUrl = 'http://localhost:8844/authcode'
ClientId = 'h366-powercli-native-Brian'
ClientSecret = 's1A9RxZ0FbBEGoMplD0HcbQITBODtX85'
}
$oauthSecContext = New-OAuthSecurityContext @newOAuthArguments
This results in our default web browser opening to an Azure / Entra AD login page. After successfully entering our credentials, we are redirected to a page that looks like the following image:

The text states: PowerCLI authenticated successfully. Please continue in the PowerShell console. You can close this window now.
If you look closely at the URL, you’ll note the page is the RedirectUrl
we specified above.
We’ll now take the $ouathSecContext
return from the previous codeblock and use it to create a $samlSecContext
and use that to connect to our vCenter.
$samlSecContext = New-VISamlSecurityContext -VCenterServer 'test-vcsa-03.lab.enterpriseadmins.org' -OAuthSecurityContext $oauthSecContext
Connect-VIServer -Server 'test-vcsa-03.lab.enterpriseadmins.org' -SamlSecurityContext $samlSecContext
The above commands will return a successful login prompt:
Name Port User
---- ---- ----
test-vcsa-03.lab.enterprisead… 443 LAB.ENTERPRISEADMINS.ORG\h163…
We can now run PowerCLI cmdlets using our federated identity.
Conclusion
Using Entra ID federation with vCenter Server 8.0 is a great way to step up your security game, especially with MFA in the mix. As we’ve seen, it can trip up tools like PowerCLI if you’re expecting username and password logins.
Thankfully, with a little setup (like creating an OAuth client and using the right security contexts), we can still automate tasks and scripts using federated identity. If this is something your team will do often, it’s worth putting together a quick internal guide or template for setting up new PowerCLI clients. It’ll save time and keep everyone on the same page.