If your vCenter Server is configured with an external identity provider, such as Microsoft Active Directory Federation Services (AD FS) or other external identity provider supported by VMware Identity Service, you can authenticate with PowerCLI by using the OAuth 2.0 Authorization Code grant type.
You can authenticate to a federated vCenter Server by creating a new OAuth security context and then exchanging it for a SAML security context. You create an OAuth security context for PowerCLI by using the New-OAuthSecurityContext cmdlet. One way to do this is to authenticate through the Authorization Code grant type, which is illustrated by this example. This workflow guarantees a substantial degree of security and can be used with multi-factor authentication.
Get-Help New-OAuthSecurityContext -full
.
Connect to a vCenter Server System Configured to Use AD FS for an External Identity Provider
If your vCenter Server is federated to Microsoft Active Directory Federation Services (AD FS), you can authenticate with PowerCLI by using the OAuth 2.0 Authorization Code grant type.
Prerequisites
- Verify that your vCenter Server system is federated to AD FS. For more information, see Federate vCenter Server to Microsoft Active Directory Federation Services (AD FS) in the VMware vSphere Automation REST API Programming Guide.
- Create an OAuth client for PowerCLI on the authentication server (AD FS). Configure the OAuth client to do the same token transformation as your vCenter Server system . You must configure a redirect URL according to the requirements in the procedure below. Save the Client ID and Client Secret that are generated by the authentication server. For more information, see the Microsoft documentation.
Procedure
Connect to a vCenter Server System Configured to Use External Identity Providers Supported by VMware Identity Services
With vSphere 8.0 Update 1, VMware Identity Services is a built-in container within vCenter Server that you can use for identity federation to external identity providers. It serves as an independent identity broker within vCenter Server and currently supports Okta, Microsoft Entra ID, and PingFederate as external identity providers. Starting with vSphere 8.0 Update 3, PowerCLI integrates with VMware Identity Services to support the use of external identity providers to authenticate to vCenter Server.
Prerequisites
- Verify that your vCenter Server system is federated to an identity provider supported by VMware Identity Service. See the Configuring vCenter Server Identity Provider Federation chapter in the vSphere Authentication guide.
- Verify that you have the vCenter Single Sign-On administrator privileges.
Procedure
Unattended Logins to a Federated vCenter Server System
Unattended logins to a federated vCenter Server system represent a security threat and must be allowed with great caution.
When you register the vCenter Server OAuth client with the OAuth provider, you can create a configuration that allows password grant type (Resource Owner Password Credentials grant type) for some users. Such users can then perform unattended logins to the federated vCenter Server system.
Connect-VIServer
cmdlet in the following way:
Connect-VIServer -Server '<vcenter_fqdn>' -User '<user_name>' -Password '<user_password>'