New-AzNetworkSecurityGroup
Creates a network security group.
New-AzNetworkSecurityGroup
-Name <String>
-ResourceGroupName <String>
-Location <String>
[-FlushConnection]
[-SecurityRules <PSSecurityRule[]>]
[-Tag <Hashtable>]
[-Force]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
The New-AzNetworkSecurityGroup cmdlet creates an Azure network security group.
New-AzNetworkSecurityGroup -Name "nsg1" -ResourceGroupName "rg1" -Location "westus"
This command creates a new Azure network security group named "nsg1" in resource group "rg1" in location "westus".
$rule1 = New-AzNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix `
Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$rule2 = New-AzNetworkSecurityRuleConfig -Name web-rule -Description "Allow HTTP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 101 -SourceAddressPrefix `
Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 80
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName TestRG -Location westus -Name `
"NSG-FrontEnd" -SecurityRules $rule1,$rule2
Step:1 Create a security rule allowing access from the Internet to port 3389.
Step:2 Create a security rule allowing access from the Internet to port 80.
Step:3 Add the rules created above to a new NSG named NSG-FrontEnd.
New-AzNetworkSecurityGroup -Name "nsg1" -ResourceGroupName "rg1" -Location "westus" -FlushConnection
This command creates a new Azure network security group named "nsg1" in resource group "rg1" in location "westus" and enables flushing of connection.
Run cmdlet in the background
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
When enabled, flows created from Network Security Group connections will be re-evaluated when rules are updated. Initial enablement will trigger re-evaluation
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Forces the command to run without asking for user confirmation.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the region for which to create a network security group.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the name of the network security group to create.
Type: | String |
Aliases: | ResourceName |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the name of a resource group. This cmdlet creates a network security group in the resource group that this parameter specifies.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies a list of network security rule objects to create in a network security group.
Type: | PSSecurityRule[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Key-value pairs in the form of a hash table. For example: @{key0="value0";key1=$null;key2="value2"}
Type: | Hashtable |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Azure PowerShell に関するフィードバック
Azure PowerShell はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。