Azure Power Shell

Télécharger au format docx, pdf ou txt
Télécharger au format docx, pdf ou txt
Vous êtes sur la page 1sur 5

# Créer le réseau virtuel 1

$vnet1 = New-AzVirtualNetwork

-Name "vnet-1"

-ResourceGroupName "TEST3"

-Location "japanEast"

-AddressPrefix "172.16.0.0/16"

# Créer le sous-réseau dans le réseau virtuel 1


Add-AzVirtualNetworkSubnetConfig

-Name "subnet-1"

-AddressPrefix "172.16.1.0/24"

-VirtualNetwork $vnet1 | Set-AzVirtualNetwork

# Créer le réseau virtuel 2


$vnet2 = New-AzVirtualNetwork

-Name "vnet-2"

-ResourceGroupName "TEST3"

-Location "japanEast"

-AddressPrefix "192.168.0.0/16"

# Créer le sous-réseau dans le réseau virtuel 2


Add-AzVirtualNetworkSubnetConfig

-Name "subnet-2"

-AddressPrefix "192.168.1.0/24"

-VirtualNetwork $vnet2 | Set-AzVirtualNetwork

# Créer l'adresse IP publique 1


New-AzPublicIpAddress

-Name "public-ip1"

-ResourceGroupName "TEST3"

-Location "japanEast"

-AllocationMethod "Static"
-Sku "Standard"

-Tier "Regional"

# Créer l'adresse IP publique 2


New-AzPublicIpAddress

-Name "public-ip2"

-ResourceGroupName "TEST3"

-Location "japanEast"

-AllocationMethod "Static"

-Sku "Standard"

-Tier "Regional"

# Créer le NSG 1
$nsg1 = New-AzNetworkSecurityGroup

-Name "nsg1"

-ResourceGroupName "TEST3"

-Location "japanEast"

# Créer la règle rdp dans le NSG 1


Add-AzNetworkSecurityRuleConfig

-Name "rulerdp"

-NetworkSecurityGroup $nsg1

-Priority 4096

-SourceAddressPrefix "*"

-SourcePortRange "*"

-DestinationAddressPrefix "*"

-DestinationPortRange 3389

-Access "Allow"

-Protocol "Tcp"

-Description "allow rdp" | Set-AzNetworkSecurityGroup

# Créer la règle ping dans le NSG 1


Add-AzNetworkSecurityRuleConfig

-Name "ruleping"

-NetworkSecurityGroup $nsg1

-Priority 500

-SourceAddressPrefix "*"

-SourcePortRange "*"

-DestinationAddressPrefix "*"

-DestinationPortRange "*"

-Access "Allow"

-Protocol "Icmp"

-Description "allow icmp" | Set-AzNetworkSecurityGroup

# Créer le NSG 2
$nsg2 = New-AzNetworkSecurityGroup

-Name "nsg2"

-ResourceGroupName "TEST3"

-Location "japanEast"

# Créer la règle rdp dans le NSG 2


Add-AzNetworkSecurityRuleConfig

-Name "rulerdp"

-NetworkSecurityGroup $nsg2

-Priority 4096

-SourceAddressPrefix "*"

-SourcePortRange "*"

-DestinationAddressPrefix "*"

-DestinationPortRange 22

-Access "Allow"

-Protocol "Tcp"

-Description "allow ssh" | Set-AzNetworkSecurityGroup


# Créer la règle ping dans le NSG 2
Add-AzNetworkSecurityRuleConfig

-Name "ruleping"

-NetworkSecurityGroup $nsg2

-Priority 500

-SourceAddressPrefix "*"

-SourcePortRange "*"

-DestinationAddressPrefix "*"

-DestinationPortRange "*"

-Access "Allow"

-Protocol "Icmp"

-Description "allow icmp" | Set-AzNetworkSecurityGroup

# Créer la carte réseau pour la VM1


$nic1 = New-AzNetworkInterface

-Name "nic1"

-ResourceGroupName "TEST3"

-Location "japanEast"

-SubnetId $vnet1.Subnets[0].Id

-PublicIpAddressId (Get-AzPublicIpAddress -ResourceGroupName "TEST3" -Name "public-ip1").Id

-NetworkSecurityGroupId $nsg1.Id

# Créer la VM1
New-AzVM

-ResourceGroupName "TEST3"

-Name "vm1"

-Location "japanEast"

-Image "Win2016Datacenter"

-Size "Standard_D2s_V3"

-Credential (Get-Credential)

-NetworkInterfaceId $nic1.Id

-OsDiskName "diskvm1"
-OsDiskSizeInGB 256

Vous aimerez peut-être aussi