25 copy-paste commands for diagnostics, networking, firewall, services, and automation. Search by name, cmdlet, or description.
Showing 25 of 25 commands
Get-ComputerInfo | Select-Object CsName, OsName, OsVersion, OsBuildNumber, OsHardwareAbstractionLayer, CsTotalPhysicalMe…
Show OS name, version, build, hardware abstraction layer, total RAM, CPU count.
Get-Counter -Counter '\Processor(_Total)\% Processor Time', '\Memory\Available MBytes' -SampleInterval 2 -MaxSamples 10
Sample CPU and memory counters every 2 seconds, 10 times.
Get-WinEvent -FilterHashtable @{LogName='System'; Level=2} -MaxEvents 50 | Format-Table TimeCreated, Id, ProviderName, M…
Read the 50 most recent System log errors using the modern event log API.
Get-NetFirewallRule -Direction Inbound -Action Allow -Enabled True | Sort-Object DisplayName | Select-Object DisplayName…
List enabled inbound allow firewall rules with port info.
Get-NetIPAddress | Where-Object AddressFamily -eq 'IPv4' | Select-Object InterfaceAlias, IPAddress, PrefixLength, Addres…
List all IPv4 addresses with interface name and prefix.
New-NetFirewallRule -DisplayName 'Custom App TCP 8080' -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow -P…
Add an inbound TCP allow rule. Optionally restrict by source IP.
Test-NetConnection -ComputerName 'google.com' -Port 443
Test if a remote TCP port is reachable. PowerShell equivalent of nc -zv.
Get-Process | Sort-Object WorkingSet64 -Descending | Select-Object -First 20 Name, Id, CPU, @{N='MB';E={[math]::Round($_…
List running processes sorted by RAM usage.
Get-Service | Select-Object Name, DisplayName, Status, StartType | Format-Table -AutoSize
List Windows services with status and startup type. Filter by name pattern.
Restart-Service -Name 'W3SVC' -Force
Restart a Windows service forcing dependents to stop/start.
Set-Service -Name 'MSSQLSERVER' -StartupType Automatic
Change a service's startup type (Automatic, Manual, Disabled).
Stop-Process -Name 'notepad' -Force
Terminate a process by name or PID. Skips cleanup code.
(Get-ChildItem -Path 'C:\inetpub' -Recurse -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum / 1…
Calculate total folder size in GB using PowerShell.
Get-PhysicalDisk | Format-Table FriendlyName, MediaType, Size, HealthStatus
List physical disks with media type (SSD/HDD/NVMe) and health status.
Get-Volume | Where-Object DriveLetter | Select-Object DriveLetter, FileSystemLabel, @{N='SizeGB';E={[math]::Round($_.Siz…
List drives with size, free space, and used percentage.
robocopy 'C:\Source' 'D:\Backup' /MIR /R:3 /W:5 /LOG:'C:\Logs\backup.log' /NP
Mirror a folder for backup. Retries on errors, logs to file.
Enable-PSRemoting -Force
Enable PowerShell remoting on a server so you can manage it from another machine.
Enter-PSSession -ComputerName 'SERVER02' -Credential (Get-Credential)
Open an interactive remote PowerShell session. Type 'exit' to leave.
Get-ChildItem -Path 'C:\' -File -Recurse -ErrorAction SilentlyContinue | Where-Object Length -gt 100MB | Select-Object F…
Recursively find files over 100 MB. Useful for disk-space cleanup.
Invoke-Command -ComputerName 'SRV01','SRV02','SRV03' -ScriptBlock { Get-WmiObject Win32_OperatingSystem | Select-Object …
Run a script block on one or more remote servers via PowerShell remoting.
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 20 HotFixID, Description, InstalledOn, Installed…
List the 20 most recently installed Windows updates.
Install-Module -Name PSWindowsUpdate -Force -Scope AllUsers; Get-WindowsUpdate -Install -AcceptAll -AutoReboot
Install + run Windows Updates from PowerShell using the PSWindowsUpdate module.
Add-LocalGroupMember -Group 'Remote Desktop Users' -Member 'jane.doe'
Add a user to a local group like Remote Desktop Users or Administrators.
Get-LocalUser | Format-Table Name, Enabled, LastLogon, Description -AutoSize
List local user accounts with enable state, last logon, description.
$password = Read-Host 'Password' -AsSecureString; New-LocalUser -Name 'jane.doe' -Password $password -FullName 'Jane Doe…
Create a new local user account interactively (prompts for password).