如何启用远程桌面用户 - Post 部署/Post 为 Azure 服务构建

How to enable Remote Desktop User - Post Deployment/ Post Build for Azure Services

想知道是否有启用 RDP post 部署的方法。 Post构建云服务?

在打包之前可以使用选项来执行此操作!

为此找到了可行的解决方案!

Set-AzureServiceRemoteDesktopExtension

您需要将 ServiceName 传递给下面的代码段。

        if(($UserName) -and ($Password))
        {
            $SecurePass = ConvertTo-SecureString -string $Password -AsPlainText -Force
            $Credential = New-Object System.Management.Automation.PSCredential $UserName, $SecurePass

            # Check if RDP is enabled for the Service
            $isRDPEnaled = Get-AzureServiceRemoteDesktopExtension -ServiceName $ServiceName
            if(!$isRDPEnaled)
            {
                # Enable RDP with the new user
                Set-AzureServiceRemoteDesktopExtension -ServiceName $ServiceName -Credential $Credential
            }
            else
            {
                if($isRDPEnaled.UserName -ne $UserName)
                {
                    # Remove RDP for the existing user
                    Remove-AzureServiceRemoteDesktopExtension -ServiceName $ServiceName
                    # Enable RDP with the new user
                    Set-AzureServiceRemoteDesktopExtension -ServiceName $ServiceName -Credential $Credential
                }
                else
                {
                    Write-Verbose ""
                    Write-Verbose " Remote Login enabled for the Service "
                }
            }
        }