PowerShell Commands
Windows PowerShell 5.1 and PowerShell 7: shell, scripting language and the base of Microsoft 365 administration.All PowerShell pages
- Compress-Archive: zip a folder in PowerShell (and unzip it with Expand-Archive)Compress-Archive -Path folder -DestinationPath out.zip zips a folder in PowerShell; Expand-Archive unzips. Zip only, files under 2 GB, hidden files skipped.
- Get-ExecutionPolicy -List: PowerShell execution policy scopes and which one winsGet-ExecutionPolicy -List shows the policy at all five scopes. The first one not Undefined wins: MachinePolicy, UserPolicy, Process, CurrentUser, LocalMachine.
- Get-FileHash: get the SHA256 or MD5 hash of a file in PowerShellGet-FileHash FILE prints a file's SHA256 hash in PowerShell; -Algorithm MD5, SHA1 or SHA512 picks another. Compare it with -eq, which ignores hex letter case.
- Select-String: the PowerShell equivalent of grepSelect-String -Path *.log -Pattern error prints matching lines with file and line number. It ignores case by default; see -CaseSensitive, -NotMatch, -Context.