PowerShell: 101-vm-with-rdp-port


Create a VM with an RDP port

Description

This is a conversion of ARM template 101-vm-with-rdp-port  from the repository azure\azure-quickstart-templates  to PowerShell Script.

This script allows you to create a NAT rule in loadbalancer to allow RDP to a vm, and it will deploy the following resources…

… and in-addition to it, just in-case if the deployment is not successful, then it will rollback the entire deployment.

Note:

If the specified resource group is already exist then the script will not continue with the deployment.

Syntax

Deploy-AzResource.ps1 [-ResourceGroupName] <string> [-Location] <string> [-VMName] <string> [-AdminCredential] <pscredential> [-DNSLabelPrefix] <string> [[-RDPPort] <int>] [<CommonParameters>]

Example

I 💙 PS> $Credential = Get-Credentials

PowerShell credential request
Enter your credentials.
User: sysadmin
Password for user sysadmin: *************

I 💙 PS> $param = @{
>> ResourceGroupName = 'test-rg'
>> Location = 'westus'
>> VMName = 'rdpvm'
>> AdminCredential = $Credential
>> DNSLabelPrefix = 'rdpvmsdjvfsdf'
>> }

I 💙 PS> .\Deploy-AzResources.ps1 @param

Output

Deployment is successful!

Code

    View the code in GitHub  
Last modified: 25 August 2020

Share it on     |   |   |   | 
comments powered by Disqus