50 Windows Commands Every Azure VM Admin Needs (PowerShell + Active Directory)

50 Windows Commands Every Azure VM Admin Needs (PowerShell + Active Directory)

Source: Dev.to

Why This List Exists ## Network Troubleshooting ## Check IP Configuration ## Test DNS Resolution ## Trace Route to Endpoint ## Check Open Ports ## Show Routing Table ## Flush DNS Cache ## Show Active Connections ## Active Directory Commands ## Join Domain ## Verify Domain Join ## Check AD Replication ## Find Domain Controllers ## Reset Computer Account ## Test Domain Trust ## Disk Management ## List All Disks ## Initialize New Disk ## Create New Partition ## Extend Volume ## Check Disk Health ## Service Management ## List All Services ## Start/Stop Service ## Set Service Startup Type ## Check Service Dependencies ## Performance & Monitoring ## Check CPU Usage ## Check Memory Usage ## Show Top CPU Processes ## Check Disk I/O ## Show Uptime ## Windows Updates ## Check for Updates ## Install Updates ## Show Update History ## User & Permission Management ## List Local Admins ## Add User to Local Admin ## Show Logged-in Users ## Force Logoff User ## Check File Permissions ## Firewall Management ## Show Firewall Rules ## Create Firewall Rule ## Disable Firewall (Testing Only!) ## Event Log Analysis ## Show Recent Errors ## Search Event Logs ## Show Security Events ## Azure-Specific Commands ## Check Azure VM Agent ## Test Azure Metadata Service ## Show Azure VM Extensions ## System Information ## Show OS Version ## Show Installed Programs ## Check System Drivers ## Show Environment Variables ## Quick Fixes ## Reset Windows Update ## Clear Temp Files ## Rebuild Windows Search Index ## Full Command Reference Azure Portal is great until: Then you need actual Windows commands. Complete command library with parameters, examples, and troubleshooting guides: 👉 50 Windows Commands Complete Guide Managing Azure VMs? Bookmark this. The Azure Portal can't do everything—sometimes you need actual Windows commands. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: Get-NetIPAddress | Format-Table InterfaceAlias, IPAddress, PrefixLength Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-NetIPAddress | Format-Table InterfaceAlias, IPAddress, PrefixLength CODE_BLOCK: Get-NetIPAddress | Format-Table InterfaceAlias, IPAddress, PrefixLength CODE_BLOCK: Resolve-DnsName azure-noob.com -Server 8.8.8.8 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Resolve-DnsName azure-noob.com -Server 8.8.8.8 CODE_BLOCK: Resolve-DnsName azure-noob.com -Server 8.8.8.8 CODE_BLOCK: tracert 10.0.1.4 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: tracert 10.0.1.4 CODE_BLOCK: tracert 10.0.1.4 CODE_BLOCK: Test-NetConnection -ComputerName 10.0.1.4 -Port 443 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Test-NetConnection -ComputerName 10.0.1.4 -Port 443 CODE_BLOCK: Test-NetConnection -ComputerName 10.0.1.4 -Port 443 CODE_BLOCK: route print Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: route print CODE_BLOCK: route print CODE_BLOCK: ipconfig /flushdns Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: ipconfig /flushdns CODE_BLOCK: ipconfig /flushdns CODE_BLOCK: netstat -ano | findstr ESTABLISHED Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: netstat -ano | findstr ESTABLISHED CODE_BLOCK: netstat -ano | findstr ESTABLISHED CODE_BLOCK: Add-Computer -DomainName contoso.com -Credential (Get-Credential) -Restart Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Add-Computer -DomainName contoso.com -Credential (Get-Credential) -Restart CODE_BLOCK: Add-Computer -DomainName contoso.com -Credential (Get-Credential) -Restart CODE_BLOCK: nltest /dsgetdc:contoso.com Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: nltest /dsgetdc:contoso.com CODE_BLOCK: nltest /dsgetdc:contoso.com CODE_BLOCK: repadmin /replsummary Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: repadmin /replsummary CODE_BLOCK: repadmin /replsummary CODE_BLOCK: Get-ADDomainController -Filter * | Select Name, IPv4Address Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-ADDomainController -Filter * | Select Name, IPv4Address CODE_BLOCK: Get-ADDomainController -Filter * | Select Name, IPv4Address CODE_BLOCK: Reset-ComputerMachinePassword -Server DC01 -Credential (Get-Credential) Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Reset-ComputerMachinePassword -Server DC01 -Credential (Get-Credential) CODE_BLOCK: Reset-ComputerMachinePassword -Server DC01 -Credential (Get-Credential) CODE_BLOCK: nltest /sc_query:contoso.com Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: nltest /sc_query:contoso.com CODE_BLOCK: nltest /sc_query:contoso.com CODE_BLOCK: Get-Disk | Format-Table Number, FriendlyName, Size, PartitionStyle Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Disk | Format-Table Number, FriendlyName, Size, PartitionStyle CODE_BLOCK: Get-Disk | Format-Table Number, FriendlyName, Size, PartitionStyle CODE_BLOCK: Initialize-Disk -Number 2 -PartitionStyle GPT Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Initialize-Disk -Number 2 -PartitionStyle GPT CODE_BLOCK: Initialize-Disk -Number 2 -PartitionStyle GPT CODE_BLOCK: New-Partition -DiskNumber 2 -UseMaximumSize -DriveLetter F Format-Volume -DriveLetter F -FileSystem NTFS -NewFileSystemLabel "Data" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: New-Partition -DiskNumber 2 -UseMaximumSize -DriveLetter F Format-Volume -DriveLetter F -FileSystem NTFS -NewFileSystemLabel "Data" CODE_BLOCK: New-Partition -DiskNumber 2 -UseMaximumSize -DriveLetter F Format-Volume -DriveLetter F -FileSystem NTFS -NewFileSystemLabel "Data" CODE_BLOCK: Resize-Partition -DriveLetter C -Size (Get-PartitionSupportedSize -DriveLetter C).SizeMax Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Resize-Partition -DriveLetter C -Size (Get-PartitionSupportedSize -DriveLetter C).SizeMax CODE_BLOCK: Resize-Partition -DriveLetter C -Size (Get-PartitionSupportedSize -DriveLetter C).SizeMax CODE_BLOCK: Get-PhysicalDisk | Select FriendlyName, HealthStatus, OperationalStatus Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-PhysicalDisk | Select FriendlyName, HealthStatus, OperationalStatus CODE_BLOCK: Get-PhysicalDisk | Select FriendlyName, HealthStatus, OperationalStatus CODE_BLOCK: Get-Service | Where-Object {$_.Status -eq "Running"} | Format-Table Name, DisplayName Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Service | Where-Object {$_.Status -eq "Running"} | Format-Table Name, DisplayName CODE_BLOCK: Get-Service | Where-Object {$_.Status -eq "Running"} | Format-Table Name, DisplayName CODE_BLOCK: Start-Service -Name "W32Time" Stop-Service -Name "Spooler" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Start-Service -Name "W32Time" Stop-Service -Name "Spooler" CODE_BLOCK: Start-Service -Name "W32Time" Stop-Service -Name "Spooler" CODE_BLOCK: Set-Service -Name "wuauserv" -StartupType Manual Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Set-Service -Name "wuauserv" -StartupType Manual CODE_BLOCK: Set-Service -Name "wuauserv" -StartupType Manual CODE_BLOCK: Get-Service -Name "W32Time" | Select -ExpandProperty DependentServices Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Service -Name "W32Time" | Select -ExpandProperty DependentServices CODE_BLOCK: Get-Service -Name "W32Time" | Select -ExpandProperty DependentServices CODE_BLOCK: Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval 1 -MaxSamples 5 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval 1 -MaxSamples 5 CODE_BLOCK: Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval 1 -MaxSamples 5 CODE_BLOCK: Get-WmiObject Win32_OperatingSystem | Select @{N="FreeGB";E={[math]::Round($_.FreePhysicalMemory/1MB,2)}} Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-WmiObject Win32_OperatingSystem | Select @{N="FreeGB";E={[math]::Round($_.FreePhysicalMemory/1MB,2)}} CODE_BLOCK: Get-WmiObject Win32_OperatingSystem | Select @{N="FreeGB";E={[math]::Round($_.FreePhysicalMemory/1MB,2)}} CODE_BLOCK: Get-Process | Sort-Object CPU -Descending | Select -First 10 Name, CPU, PM Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Process | Sort-Object CPU -Descending | Select -First 10 Name, CPU, PM CODE_BLOCK: Get-Process | Sort-Object CPU -Descending | Select -First 10 Name, CPU, PM CODE_BLOCK: Get-Counter '\PhysicalDisk(_Total)\Disk Reads/sec','\PhysicalDisk(_Total)\Disk Writes/sec' Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Counter '\PhysicalDisk(_Total)\Disk Reads/sec','\PhysicalDisk(_Total)\Disk Writes/sec' CODE_BLOCK: Get-Counter '\PhysicalDisk(_Total)\Disk Reads/sec','\PhysicalDisk(_Total)\Disk Writes/sec' CODE_BLOCK: (Get-Date) - (gcim Win32_OperatingSystem).LastBootUpTime Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: (Get-Date) - (gcim Win32_OperatingSystem).LastBootUpTime CODE_BLOCK: (Get-Date) - (gcim Win32_OperatingSystem).LastBootUpTime CODE_BLOCK: Get-WindowsUpdate Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-WindowsUpdate CODE_BLOCK: Get-WindowsUpdate CODE_BLOCK: Install-WindowsUpdate -AcceptAll -AutoReboot Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Install-WindowsUpdate -AcceptAll -AutoReboot CODE_BLOCK: Install-WindowsUpdate -AcceptAll -AutoReboot CODE_BLOCK: Get-WmiObject -Class Win32_QuickFixEngineering | Select HotFixID, InstalledOn Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-WmiObject -Class Win32_QuickFixEngineering | Select HotFixID, InstalledOn CODE_BLOCK: Get-WmiObject -Class Win32_QuickFixEngineering | Select HotFixID, InstalledOn CODE_BLOCK: Get-LocalGroupMember -Group "Administrators" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-LocalGroupMember -Group "Administrators" CODE_BLOCK: Get-LocalGroupMember -Group "Administrators" CODE_BLOCK: Add-LocalGroupMember -Group "Administrators" -Member "CONTOSO\john.doe" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Add-LocalGroupMember -Group "Administrators" -Member "CONTOSO\john.doe" CODE_BLOCK: Add-LocalGroupMember -Group "Administrators" -Member "CONTOSO\john.doe" CODE_BLOCK: query user Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: logoff 2 /server:localhost Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: logoff 2 /server:localhost CODE_BLOCK: logoff 2 /server:localhost CODE_BLOCK: Get-Acl C:\Important\File.txt | Format-List Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Acl C:\Important\File.txt | Format-List CODE_BLOCK: Get-Acl C:\Important\File.txt | Format-List CODE_BLOCK: Get-NetFirewallRule | Where Enabled -eq True | Select Name, DisplayName Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-NetFirewallRule | Where Enabled -eq True | Select Name, DisplayName CODE_BLOCK: Get-NetFirewallRule | Where Enabled -eq True | Select Name, DisplayName CODE_BLOCK: New-NetFirewallRule -DisplayName "Allow SQL" -Direction Inbound -Protocol TCP -LocalPort 1433 -Action Allow Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: New-NetFirewallRule -DisplayName "Allow SQL" -Direction Inbound -Protocol TCP -LocalPort 1433 -Action Allow CODE_BLOCK: New-NetFirewallRule -DisplayName "Allow SQL" -Direction Inbound -Protocol TCP -LocalPort 1433 -Action Allow CODE_BLOCK: Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False CODE_BLOCK: Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False CODE_BLOCK: Get-EventLog -LogName System -EntryType Error -Newest 20 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-EventLog -LogName System -EntryType Error -Newest 20 CODE_BLOCK: Get-EventLog -LogName System -EntryType Error -Newest 20 CODE_BLOCK: Get-EventLog -LogName Application | Where-Object {$_.Message -like "*SQL*"} Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-EventLog -LogName Application | Where-Object {$_.Message -like "*SQL*"} CODE_BLOCK: Get-EventLog -LogName Application | Where-Object {$_.Message -like "*SQL*"} CODE_BLOCK: Get-EventLog -LogName Security -InstanceId 4624 -Newest 10 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-EventLog -LogName Security -InstanceId 4624 -Newest 10 CODE_BLOCK: Get-EventLog -LogName Security -InstanceId 4624 -Newest 10 CODE_BLOCK: Get-Service WindowsAzureGuestAgent Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Service WindowsAzureGuestAgent CODE_BLOCK: Get-Service WindowsAzureGuestAgent CODE_BLOCK: Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri "http://169.254.169.254/metadata/instance?api-version=2021-02-01" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri "http://169.254.169.254/metadata/instance?api-version=2021-02-01" CODE_BLOCK: Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri "http://169.254.169.254/metadata/instance?api-version=2021-02-01" CODE_BLOCK: Get-AzVMExtension -ResourceGroupName "RG-Prod" -VMName "VM-SQL-01" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-AzVMExtension -ResourceGroupName "RG-Prod" -VMName "VM-SQL-01" CODE_BLOCK: Get-AzVMExtension -ResourceGroupName "RG-Prod" -VMName "VM-SQL-01" CODE_BLOCK: Get-ComputerInfo | Select WindowsProductName, WindowsVersion, OsBuildNumber Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-ComputerInfo | Select WindowsProductName, WindowsVersion, OsBuildNumber CODE_BLOCK: Get-ComputerInfo | Select WindowsProductName, WindowsVersion, OsBuildNumber CODE_BLOCK: Get-WmiObject -Class Win32_Product | Select Name, Version Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-WmiObject -Class Win32_Product | Select Name, Version CODE_BLOCK: Get-WmiObject -Class Win32_Product | Select Name, Version CODE_BLOCK: Get-WindowsDriver -Online Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-WindowsDriver -Online CODE_BLOCK: Get-WindowsDriver -Online CODE_BLOCK: set Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: net stop wuauserv del C:\Windows\SoftwareDistribution\*.* /s /q net start wuauserv Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: net stop wuauserv del C:\Windows\SoftwareDistribution\*.* /s /q net start wuauserv CODE_BLOCK: net stop wuauserv del C:\Windows\SoftwareDistribution\*.* /s /q net start wuauserv CODE_BLOCK: Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue CODE_BLOCK: Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue CODE_BLOCK: Get-Service WSearch | Restart-Service Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: Get-Service WSearch | Restart-Service CODE_BLOCK: Get-Service WSearch | Restart-Service - RDP is slow - You need to fix networking - Active Directory breaks - You're troubleshooting 50 VMs