Found 463 Articles for PowerShell

How to get the update domain count of the Azure Availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:54:09

131 Views

Virtual machines inside the Availability set get the update automatically, they reboot together and they are used for the patching of the virtual machines.To get the update domain count from the availability set, we can use the below command.Before running this command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)To get the availability set,$availablityset = Get-AzAvailabilitySet -ResourceGroupName Resourcegroupname -Name AvailabilitySetNameTo get the update domain count,$availablityset.PlatformUpdateDomainCountOutput

How to get the fault domain count of the Azure Availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:44:49

148 Views

The fault domain in the Azure Availability set describes the VMs in the availability set that share the common Power, Storage, network switch, etc. If there is a failure in the fault domain then all the resources in the fault domain will become unavailable.Before running the command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)$availablityset = Get-AzAvailabilitySet -ResourceGroupName ResourceGroupName -Name AvailabilitySetNameTo get the Fault domain countm$availablityset.PlatformFaultDomainCountOutput

How to list the Azure VMs from the Availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:50:46

442 Views

To list the Azure VMs under the availability set, we can use the command as shown belowBefore running the command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)$availabilitySetVMs = Get-AzAvailabilitySet -ResourceGroupName MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySetTo get the total number of Virtual machines in the availability set, PS C:\> $availabilitySetVMs.VirtualMachinesReferences.id.countOutputTo get all the VM names from the list, we can use the below command.$VMlist = Get-AzAvailabilitySet -ResourceGroupName MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet $i=0 foreach($vm in $VMlist.VirtualMachinesReferences){    "VM{0}: {1}" -f $i, ($vm.Id.Split('/'))[-1]    $i++ }OutputRead More

How to open port for the Azure VM using Azure CLI in PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:37:04

2K+ Views

To open the specific port for the Azure VM using Azure CLI, we can use az vm open-port command. Before running this command, make sure that you are connected with the Azure Cloud account and the proper Azure subscription.To open port 80 we can use the below command.az vm open-port -n Win2k16VM1 -g testvmrg --port 80The above command will open port 80 on the VM win2k16vm1 and the resource group testvmrg.To open the port with the highest priority, you can add the --priority parameteraz vm open-port -n Win2k16VM1 -g testvmrg --port 80 --priority 100To open the port range, az vm open-port ... Read More

How to resize the Azure VM using Azure CLI in PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:35:32

742 Views

To resize the Azure VM using az CLI, we can use “az vm resize” command. Before running this command, make sure you are connected to the Azure cloud and the proper Azure subscription.To get the current size of the VM, PS C:\> az vm show -n Win2k16VM1 -g testvmrg --query 'hardwareProfile.vmSize'Output"Standard_B2ms"Here, -n is the VM name, and -g is the resource group name.To get the VM location, PS C:\> az vm show -n Win2k16VM1 -g testvmrg --query 'location'Output"eastus" We will now get all the sizes available at the particular location so that we can resize the VM from the sizes ... Read More

How to list the azure VM extensions using Azure CLI in PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:33:47

829 Views

To list all the azure VM extensions using Azure CLI, we can use the “az vm extension” command.Before running this command make sure you are connected with the Azure cloud account and the Azure subscription. Once we run the command for the extension we need to provide the VM name and the resource group name as shown below.PS C:\> az vm extension list --vm-name Win2k16VM1 -g TESTVMRGThe output will be in the JSON format, we can use the parameter -otable to get the output in the table format.PS C:\> az vm extension list --vm-name Win2k16VM1 -g TESTVMRG -otableOutputRead More

How to get all the available azure VM images using Azure CLI in PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:31:52

2K+ Views

To get all the available azure VM images using Azure CLI, you can use the command az vm image.The below command will retrieve all the available azure images in the marketplace.PS C:\> az vm image list --allThe above command will take some time to retrieve the output. To get the output into the table format, use the below command.PS C:\> az vm image list --all -otableTo retrieve the images from the particular location, use the -l or --location parameter.PS C:\> az vm image list -l eastus -otableOutputTo get the VM images from the specific publisher, PS C:\> az vm image ... Read More

How to get the available azure VM size using Azure CLI in PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:28:20

1K+ Views

To get all the available Azure VM sizes using Azure CLI from the specific location, we can use the az vm list-sizes command.PS C:\> az vm list-sizes -l eastusThe default output is in the JSON format, as shown below.To get the output in the table format, use the below command.PS C:\> az vm list-sizes -l eastus -otableOutput

How to restart the Azure VM using Azure CLI in PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:27:17

2K+ Views

To restart the Azure VM using PowerShell, we can use the az vm restart command. This command requires the Azure VM in the running status. You also require to connect to the Azure cloud account and the proper azure subscription before running this command.Let assume our VM win2k16vm1 is currently on. We need to restart this VM. Here, -n is the VM name, and -g is the resource group name.PS C:\> az vm restart -n vmname -g RGname --verboseYou can also provide the full parameter name as shown below.PS C:\> az vm restart --name win2k16vm1 --resource-group testvmrgIf the VM is unresponsive, ... Read More

How to stop the Azure VM using Azure CLI in PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:25:49

3K+ Views

To stop the azure VM using Azure CLI we can use the az vm stop command. Before running this command make sure that you are connected to the Azure account and the proper Azure subscription.When we run this command, we need to provide the Azure VM name (-n) and the resource group name (-g).PS C:\> az vm stop -n Win2k16VM1 -g TESTVMRG --verboseThe above command will stop the Azure VM Win2k16VM1 from the resource group TestVMRG. Alternatively, you can also use the full parameter name as shown below.PS C:\> az vm stop --name win2k16vm1 --resource-group testvmrgThis command will wait until ... Read More

Advertisements