PowerShell for Administrators

PowerShell is regular in a way that makes it guessable: every cmdlet is a verb and a noun. Learning the verbs and the discovery cmdlets is worth more than memorising any particular command.

Discovery, which replaces memorising

CommandWhat it does
Get-Command -Noun ServiceEvery cmdlet acting on services
Get-Help Get-Service -ExamplesWorked examples for a cmdlet
Get-MemberWhat properties and methods an object has
Get-VerbThe approved verbs and what each one implies
Update-HelpDownload current help content

Windows administration

CommandWhat it does
Get-Service -Name W32TimeService state
Restart-Service -Name SpoolerRestart a service
Get-Process | Sort CPU -DescendingProcesses by CPU
Stop-Process -Id 1234 -ForceTerminate a process
Get-EventLog -LogName Security -Newest 50Recent security events
Get-WinEvent -FilterHashtable @{LogName='Security';ID=4625}Failed logons only
Get-LocalUser / Get-LocalGroupMemberLocal accounts and group membership
Test-NetConnection host -Port 443Connectivity to a port
Get-NetIPConfigurationAddressing, gateway and DNS
Get-ChildItem -Recurse -Filter *.logRecursive file search
Set-ExecutionPolicy RemoteSignedAllow local scripts to run

Azure and Entra ID

CommandWhat it does
Connect-AzAccountSign in to Azure
Get-AzSubscriptionSubscriptions you can reach
Set-AzContext -Subscription NAMEChoose the working subscription
Get-AzResourceGroupResource groups
New-AzVM -Name web01 -ResourceGroupName rgCreate a virtual machine
Get-AzRoleAssignment -Scope /subscriptions/IDWho has what access
New-AzRoleAssignment -RoleDefinitionName ReaderGrant a role
Connect-MgGraph -Scopes User.Read.AllSign in to Microsoft Graph
Get-MgUser -AllEntra ID users

Pipeline and structure

PatternWhat it does
Where-Object { $_.Status -eq 'Running' }Filter objects by a property
Select-Object Name, StatusChoose which properties to keep
Sort-Object -Property CPU -DescendingOrder results
ForEach-Object { ... }Act on each object
Export-Csv out.csv -NoTypeInformationWrite results to CSV
| Out-GridViewOpen results in a sortable window
$var = Get-ServiceStore objects, not text. This is the difference from a shell

Now test yourself

Memorizing a table is a start. Practice questions are what make it stick, and every answer carries the full explanation.