I'm working on a powershell script to enable virtual machine creation and the maximum number of virtual machines (252) on a devTestLab's subnet : Azure Subnets

I tried to use the IpConfigurations function but it always returns "null" with my subnet unfortunately :

       $subnetCree = Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet
            write-host $subnetCree.IpConfigurations
            if ($subnetCree.IpConfigurations -ne $null) {
                  
            $subnetCree.IpConfigurations[0].PrivateIpAddressAllocationMethod = "Dynamic"
            $subnetCree.IpConfigurations[0].ApplicationGatewayBackendAddressPools = @()
            $subnetCree.IpConfigurations[0].ServiceEndpoints = @()
            $subnetCree.IpConfigurations[0].LoadBalancerBackendAddressPools = @()
            $subnetCree.IpConfigurations[0].LoadBalancerInboundNatRules = @()
            $subnetCree.IpConfigurations[0].MaximumVMs = 252
            }else{
                write-host "ip configuration null"
            }

Here is what it returns to me : resultConsole

I also tried with this function :

$subnetCree.MaxVMsPerUser = 252

But I have this result:

Property 'MaxVMsPerUser' could not be found in this object. Verify that it exists and can be set.

Anyone have an idea please? Thanks very much.

0

There are 0 best solutions below