< Back

Add-AzureNSGRuleForRemoteLocation

Tue Jan 14, 2020 12:35 am

NAME Add-AzureNSGRuleForRemoteLocation



SYNOPSIS

Adding a rule to NSG(s) to allow connection from current location





SYNTAX

Add-AzureNSGRuleForRemoteLocation [-SubscriptionId] <Object> [-rgName] <Object> [-vmName] <Object> [-OS] <Object>

[[-Port] <Object>] [[-ruleName] <Object>] [<CommonParameters>]





DESCRIPTION

This cmdlet identifies your current IP and adds a rule in virtual machine's NSG(s) to allow connection





PARAMETERS

-SubscriptionId <Object>

Subscription ID for the subscription that virtual machine is on. Required



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-rgName <Object>

The Resource Group the virtual machine belongs to. Required



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-vmName <Object>

The name of the virtual machine. Required



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OS <Object>

Select OS to automatically set port default connection port, Linux: 22 & Windows: 3389.



Required? true

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Port <Object>

The destination port number on the Network Security Group (NSG).



Required? false

Position? 5

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ruleName <Object>

Provide a name for the custom rule.



Required? false

Position? 6

Default value AllowRuleForRemoteLocation

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Author : Hannel Hazeley - hhazeley@outlook.com



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Add-AzureNSGRuleForRemoteLocation -SubscriptionId 1d6737e7-4f6c-4e3c-8cd4-996b6f003d0e -rgName DDemo

-vmName DDemo-VM2



This will create a custom rule using default port (3389) as destination port, default name

(AllowRuleForRemoteLocation) and current public IP as Source IP.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Add-AzureNSGRuleForRemoteLocation -SubscriptionId 1d6737e7-4f6c-4e3c-8cd4-996b6f003d0e -rgName DDemo

-vmName DDemo-VM2 -Port 22 -ruleName AllowSSH



This will create a custom rule using port 22 as destination port, 'AllowSSH' as name and current public IP as

Source IP.











RELATED LINKS

https://github.com/hhazeley/HannelsTool ... cation.ps1