Find Azure VM Username (PowerShell)
cmd: Get-AzVM -Name "_add_AzureVM_name_" -ResourceGroup "_add_AzureResourceGroup_name_" | Select -ExpandProperty OSProfile
Azure PowerShell command to view the VM OS profile details:
cmd: Get-AzVM -Name "_add_AzureVM_name_" -ResourceGroup "_add_AzureResourceGroup_name_" | Select -ExpandProperty OSProfile | Select -ExpandProperty WindowsConfiguration
Get Azure VM Properties (PowerShell)
cmd: Get-AzVM
Find all the Azure VM properties using PowerShell:
Get-AzVM -Name "_add_AzureVM_name_" -ResourceGroup "_add_AzureResourceGroup_name_"
This command returns Azure VM ResourceGroupName, Id, VmId, Name, Type, Location, Tags, DiagnosticsProfile, Extensions, HardwareProfile, NetworkProfile, OSProfile, ProvisioningState, StorageProfile
Get all the Azure VM Extentions Properties (PowerShell)
Get only the Name of Extentions of Azure VM (PowerShell)
Get Azure VM Extensions Details (PowerShell)
Get Azure VM Size (PowerShell)
Get Azure VM Storage Profile Details (PowerShell)
Get VM Diagnostics Profile Details (PowerShell)
Get Status of Azure VM (PowerShell)
Get Azure Security Compliance Report (PowerShell)
Windows Azure VM Run Commands
Windows Run Command uses the VM agent to let you run a script inside the target virtual machine. This can be helpful for troubleshooting and recovery, and for general machine and application maintenance.
Note: In order to use Run Command the VM should be in running state.
Step 1: Login to Azure Portal and access the target Azure Virtual Machine in which you want to enable the run commands
Step 2: Navigate to Operations >> Run command >> Select your required command to execute
List of Azure VM Run Commands:
RunPowerShellScript: Executes a PowerShell script
DisableNLA: Disable Network Level Authentication
DisableWindowsUpdate: Disable Windows Update Automatic Updates
EnableAdminAccount: Enable administrator account
Checks if the local Administrator account is disabled, and if so enables it.
EnableEMS: Enable EMS
EnableRemotePS: Enable remote PowerShell
EnableWindowsUpdate: Enable Windows Update Automatic Updates
Enable Automatic Updates through Windows Update.
IPConfig: List IP configuration
Shows detailed information for the IP address, subnet mask and default gateway for each adapter bound to TCP/IP.
RDPSettings: Verify RDP Listener Settings
ResetRDPCert: Restore RDP Authentication mode to defaults
SetRDPPort: Set Remote Desktop port
Use Az Rest cmdlets to find more details about the resources in Azure:
- az rest command to get the properties of the all the provisioned resources with resource created time with in the subscription.
az rest \
--method GET \
--url "https://management.azure.com/subscriptions/{add_subscripion_id_here}/resources/" \
--url-parameters api-version=2020-06-01 \$expand=createdTime
- az rest command to get the properties of the all the provisioned storage account resources with in the subscription.
az rest \
--method GET \
--url "https://management.azure.com/subscriptions/{add_subscripion_id_here}/providers/Microsoft.Storage/storageAccounts/" \
--url-parameters api-version=2021-09-01
List Azure Modules Name, Version, Exported Commands
Get Azure Modules List with Properties
- cmd: get-module -list
- cmd: get-module -listavailable
Sample Output:
- cmd: get-module -list | select-object Name
Sample Output:
- cmd: get-module -list | select-object Name,ExportedCommands
Sample Output:
Check Azure AD Users Properties
Get the list of Azure AD Users
- cmd: Get-AzADUser
returns all the properties of Azure AD
Get the Count of Azure AD Users
- cmd: (Get-AzADUser).count
returns the count of Azure AD users.
Get the First 10 Azure AD Users
- cmd: get-azaduser -first 10
returns DisplayName, Id, Mail, UserPrincipalName of first 10 from the list.
Get-AdUser Export To CSV File
- cmd: Get-AzADUser | Export-CSV -Path TestUsers.csv