Useful Sysadmin Commands for Azure VM troubleshooting
Scenario:
So, Now what?
Here's a few commands that seem to come up on troubleshooting calls with my team mates and on calls with Microsoft support folks, at crazy hours. These are "Run Command" friendly, using the Run PowerShell script option:
## note the session id for who you need to logoff
quser
## log off the user by their session id number
logoff <sessionid>
quser /server:<servername>
logoff <sessionid> /server:<servername>
Get-CimInstance Win32_LogicalDisk -Filter "DriveType = 3" | select DeviceID, VolumeName, @{l='Size'; e={[math]::Round($_.Size/1GB,2)}}, @{l='Free'; e={[math]::Round($_.FreeSpace/1GB,2)}}
Don't worry about running this script. I have used it plenty of times in real production environments, and nobody has lived to complain about it.
领英推荐
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /s
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\WindowsUpdate /s
(Note: PowerShell likes HKLM:\... because it's a registered path in PSDrive, one of the Registry PSProviders. But the reg.exe command does whatever it wants and says colons aren't allowed outside of a doctor's office)
Get-WinEvent -LogName Application | where {$_.LevelDisplayName -ne 'Information'} | select TimeCreated, Id, ProviderName, LevelDisplayName, Message -First 5
Note: If you don't have time to cook up an XPath query, you can pipe through Where-Object{} to filter on properties, but it can run a bit slower.
Honorable Mentions, which may depend on the Windows version:
ipconfig /flushdns
ipconfig /registerdns
ipconfig /all
net localgroup administrators
There are many more, but these should keep you busy long enough for me to slip out the back and run away before you ask questions.