Example Azure Cmdlets

Overview:

The Azure PowerShell module includes a wide range of cmdlets to manage Azure resources. Here are some of the most commonly used cmdlets:

Resource Management:

  • Get-AzResourceGroup: Retrieves information about resource groups.

    Get-AzResourceGroup -Name "ResourceGroupName"
  • New-AzResourceGroup: Creates a new resource group.

    New-AzResourceGroup -Name "ResourceGroupName" -Location "EastUS"
  • Remove-AzResourceGroup: Deletes a resource group.

    Remove-AzResourceGroup -Name "ResourceGroupName"

Virtual Machines:

  • Get-AzVM: Retrieves information about virtual machines.

    Get-AzVM -ResourceGroupName "ResourceGroupName" -Name "VMName"
  • New-AzVM: Creates a new virtual machine.

    New-AzVM -ResourceGroupName "ResourceGroupName" -Name "VMName" -Location "EastUS"
  • Start-AzVM: Starts a virtual machine.

    Start-AzVM -ResourceGroupName "ResourceGroupName" -Name "VMName"
  • Stop-AzVM: Stops a virtual machine.

    Stop-AzVM -ResourceGroupName "ResourceGroupName" -Name "VMName"

Storage Accounts:

  • Get-AzStorageAccount: Retrieves information about storage accounts.

    Get-AzStorageAccount -ResourceGroupName "ResourceGroupName"
  • New-AzStorageAccount: Creates a new storage account.

    New-AzStorageAccount -ResourceGroupName "ResourceGroupName" -Name "StorageAccountName" -Location "EastUS" -SkuName "Standard_LRS"
  • Remove-AzStorageAccount: Deletes a storage account.

    Remove-AzStorageAccount -ResourceGroupName "ResourceGroupName" -Name "StorageAccountName"

Networking:

  • Get-AzVirtualNetwork: Retrieves information about virtual networks.

    Get-AzVirtualNetwork -ResourceGroupName "ResourceGroupName" -Name "VNetName"
  • New-AzVirtualNetwork: Creates a new virtual network.

    New-AzVirtualNetwork -ResourceGroupName "ResourceGroupName" -Name "VNetName" -AddressPrefix "10.0.0.0/16" -Location "EastUS"
  • Remove-AzVirtualNetwork: Deletes a virtual network.

    Remove-AzVirtualNetwork -ResourceGroupName "ResourceGroupName" -Name "VNetName"

Documentation Reference:

Last updated