The Black Cloud

Azure Local - How to enable RDP

For quite a while now Azure Local ships with Remote Desktop Protocol (RDP) disabled. Most of the operations are typically managed via PowerShell Remote (WinRM) sessions these days, but occasionally you still want to use RDP to connect to the Azure Local host.

There are plenty of ways to enable that in Windows Server, as it requires ports opening, registry changes, etc. All of which can be done via PowerShell and was already covered in many blogs and articles. The fun fact about Azure Local though is that it actually has a built-in way to enable RDP, which is what I am going to show you in this post.

Enable RDP on Azure Local via PowerShell

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#region Connect to cluster

$SeedNode = "YOUR_SEED_NODE_NAME_FQDN" # e.g. "node01.domain.com"

$Session = New-PSSession -ComputerName $SeedNode -Credential (Get-Credential) -Authentication CredSSP

#endregion

#region Enable RDP for all nodes

Invoke-Command -Session $Session -ScriptBlock {

    $Nodes = Get-ClusterNode

    foreach ($Node in $Nodes) {

        Invoke-Command -ComputerName $Node.Name -ScriptBlock {

            Enable-ASRemoteDesktop

        }

    }

}

#endregion
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#region Connect to cluster

$SeedNode = "YOUR_SEED_NODE_NAME_FQDN" # e.g. "node01.domain.com"

$Session = New-PSSession -ComputerName $SeedNode -Credential (Get-Credential)

#endregion

#region Get cluster nodes

$Nodes = Invoke-Command -Session $Session -ScriptBlock {

    $Nodes = Get-ClusterNode

    return $Nodes

}

#endregion

#region Enable RDP for all nodes

foreach ($Node in $Nodes) {

    Invoke-Command -Session $Node -ScriptBlock {

        Enable-ASRemoteDesktop

    }

}

#endregion

Disable RDP on Azure Local via PowerShell

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#region Connect to cluster

$SeedNode = "YOUR_SEED_NODE_NAME_FQDN" # e.g. "node01.domain.com"

$Session = New-PSSession -ComputerName $SeedNode -Credential (Get-Credential) -Authentication CredSSP

#endregion

#region Disable RDP for all nodes

Invoke-Command -Session $Session -ScriptBlock {

    $Nodes = Get-ClusterNode

    foreach ($Node in $Nodes) {

        Invoke-Command -ComputerName $Node.Name -ScriptBlock {

            Disable-ASRemoteDesktop

        }

    }

}

#endregion
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#region Connect to cluster

$SeedNode = "YOUR_SEED_NODE_NAME_FQDN" # e.g. "node01.domain.com"

$Session = New-PSSession -ComputerName $SeedNode -Credential (Get-Credential)

Enter-PSSession -Session $Session

#endregion

#region Get cluster nodes

$Nodes = Invoke-Command -Session $Session -ScriptBlock {

    $Nodes = Get-ClusterNode

    return $Nodes

}

#endregion

#region Disable RDP for all nodes

foreach ($Node in $Nodes) {

    Invoke-Command -Session $Node -ScriptBlock {

        Disable-ASRemoteDesktop

    }

}

#endregion

How did we find it?

The cmdlet does not exist in a module that you can find in PowerShell Gallery or in the standard Windows Server modules. It is specific to Azure Local. It exists in its own module AzureStackOSConfigAgent.

Get the module name

1
2
3
4
5
Get-Command -Name Enable-ASRemoteDesktop

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Enable-ASRemoteDesktop                             0.0        AzureStackOSConfigAgent

Get the module details

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$ModuleUsed = (Get-Command -Name Enable-ASRemoteDesktop).Source

Get-Module -Name $ModuleUsed | Select-Object -Property Name, Path, Version, ModuleBase, ExportedCommands


Name             : AzureStackOSConfigAgent
Path             : C:\Program Files\WindowsPowerShell\Modules\AzureStackOSConfigAgent\AzureStackOSConfigAgent.psm1
Version          : 0.0
ModuleBase       : C:\Program Files\WindowsPowerShell\Modules\AzureStackOSConfigAgent
ExportedCommands : {[Confirm-AzSSecureBootUpdateBIOSFirmwareReadiness, Confirm-AzSSecureBootUpdateBIOSFirmwareReadiness],
                   [Disable-ASBuiltInAdministrator, Disable-ASBuiltInAdministrator], [Disable-ASRemoteDesktop, Disable-ASRemoteDesktop],
                   [Disable-ASSecurity, Disable-ASSecurity]...}

Get other commands in this module

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$ModuleUsed = (Get-Command -Name Enable-ASRemoteDesktop).Source
$ExportedCommands = (Get-Module -Name $ModuleUsed | Select-Object -ExpandProperty ExportedCommands).Keys
$ExportedCommands
Confirm-AzSSecureBootUpdateBIOSFirmwareReadiness
Disable-ASBuiltInAdministrator
Disable-ASRemoteDesktop
Disable-ASSecurity
Enable-ASBuiltInAdministrator
Enable-ASRemoteDesktop
Enable-ASSecurity
Export-OSConfigDiagnostics
Get-ASOSConfigDefenderAVDoc
Get-ASOSConfigSecuredCoreDoc
Get-ASOSConfigSecuritySettingsDoc
Get-ASRemoteDesktop
Get-ASSecurity
Get-AzSBootManagerUpdateStatus
Import-ASOSConfigModule
Import-AzsOSConfigBaselineMetaData
Rename-ASBuiltInAdministrator
Set-ASLocalOSConfigSecuritySettings
Start-ASDefenderAntivirusConfiguration
Start-ASSecuredCoreConfiguration
Start-ASSecuritySettingsConfiguration
Start-AzSSecureBoot2023Update
Test-AzSSecureBootUpdateCompleted
Disable-AzSSecurity
Enable-AzSSecurity
Get-AzSOSConfigDefenderAVDoc
Get-AzSOSConfigSecuredCoreDoc
Get-AzSOSConfigSecuritySettingsDoc
Get-AzSSecurity
Import-AzSOSConfigModule
Start-AzSDefenderAntivirusConfiguration
Start-AzSDefenderAVConfiguration
Start-AzSSecuredCoreConfiguration
Start-AzSSecuritySettingsConfiguration

Additional notes

<< Previous Post

|

Next Post >>

#Blog #PowerShell #Azure Local #RDP