Edit

Share via


Add-RdsAccount

Adds an authenticated account to use for Windows Virtual Desktop cmdlet requests.

Syntax

AddAccountWithCredential (Default)

Add-RdsAccount
    [-DeploymentUrl] <String>
    [[-Credential] <PSCredential>]
    [<CommonParameters>]

AddAccountWithServicePrincipal

Add-RdsAccount
    [-DeploymentUrl] <String>
    [-Credential] <PSCredential>
    [-AadTenantId] <String>
    [-ServicePrincipal]
    [<CommonParameters>]

AddAccountWithThumbprint

Add-RdsAccount
    [-DeploymentUrl] <String>
    [-CertificateThumbprint] <String>
    [-ApplicationId] <String>
    [-AadTenantId] <String>
    [<CommonParameters>]

Description

The Add-RdsAccount cmdlet adds an authenticated account to use for Windows Virtual Desktop cmdlet requests. Upon completion, the context is automatically set to use the "Default Tenant Group" as the tenant group name. You can run the Set-RdsContext cmdlet to change the context.

Examples

Example 1: Connect to Windows Virtual Desktop through an interactive login

PS C:\> Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com"

DeploymentUrl                       TenantGroupName       UserName
-------------                       ---------------       --------
https://rdbroker.wvd.microsoft.com  Default Tenant Group  admin@contoso.com

This command connects to a work or school account. To run Windows Virtual Desktop cmdlets with this account, you must provide organizational ID credentials at the prompt. If multi-factor authentication is enabled for your credentials, you must log in using the interactive option or use service principal authentication.

Example 2: Connect to Windows Virtual Desktop using organizational ID credentials

PS C:\> $Credential = Get-Credential
PS C:\> Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com"

DeploymentUrl                       TenantGroupName       UserName
-------------                       ---------------       --------
https://rdbroker.wvd.microsoft.com  Default Tenant Group  admin@contoso.com

The first command will prompt for user credentials (username and password), and then stores them in the $Credential variable. The second command connects to the Azure AD account using the credentials stored in $Credential. This account authenticates with Windows Virtual Desktop using organizational ID credentials. If multi-factor authentication is enabled for your credentials, you must log in using the interactive option or use service principal authentication.

Example 3: Connect to Windows Virtual Desktop using a service principal account with password credentials

PS C:\> $Credential = Get-Credential
PS C:\> Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com" -ServicePrincipal -AadTenantId "xxxx-xxxx-xxxx-xxxx"

DeploymentUrl                       TenantGroupName       UserName
-------------                       ---------------       --------
https://rdbroker.wvd.microsoft.com  Default Tenant Group  admin@contoso.com

The first command gets the service principal credentials (Application ID and service principal secret), and then stores them in the $Credential variable. The second command connects to the Azure AD account using the service principal credentials stored in $Credential for the specified Tenant. The ServicePrincipal switch parameter indicates that the account authenticates as a service principal.

Example 4: Connect to Windows Virtual Desktop using a service principal account with certificate credentials

# For more information on creating a self-signed certificate
# and giving it proper permissions, please see the following:
# https://learn.microsoft.com/azure/active-directory/develop/howto-authenticate-service-principal-powershell
PS C:\> $Thumbprint = "0SZTNJ34TCCMUJ5MJZGR8XQD3S0RVHJBA33Z8ZXV"
PS C:\> $TenantId = "aaaabbbb-0000-cccc-1111-dddd2222eeee"
PS C:\> $ApplicationId = "00001111-aaaa-2222-bbbb-3333cccc4444"
PS C:\> Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com" -CertificateThumbprint $Thumbprint -ApplicationId $ApplicationId -AadTenantId $TenantId

DeploymentUrl                       TenantGroupName       UserName
-------------                       ---------------       --------
https://rdbroker.wvd.microsoft.com  Default Tenant Group  admin@contoso.com

Parameters

-AadTenantId

Specifies the Azure AD tenant ID from which the service principal is a member.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:TenantId

Parameter sets

AddAccountWithServicePrincipal
Position:3
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
AddAccountWithThumbprint
Position:3
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ApplicationId

The application ID of the service principal to authenticate to Windows Virtual Desktop.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AddAccountWithThumbprint
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-CertificateThumbprint

The thumbprint for the installed certificate to authenticate as the service principal to Windows Virtual Desktop.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AddAccountWithThumbprint
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Credential

Specifies a PSCredential object. For more information about the PSCredential object, type Get-Help Get-Credential. The PSCredential object provides the user ID and password for organizational ID credentials, or the application ID and secret for service principal credentials.

Parameter properties

Type:PSCredential
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AddAccountWithCredential
Position:1
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DeploymentUrl

The Universal Resource Locator (URL) string pointing to the Windows Virtual Desktop management site.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ServicePrincipal

Switch indicating that this account authenticates by providing service principal credentials.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AddAccountWithServicePrincipal
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

Microsoft.RDInfra.RDManagementData.RdMgmtContext