Powershell

Updated: November 24, 2025

Neat things to do in power shell.

Table of Contents

BIOS

Restart and Boot into BIOS

# fw is for firmware (BIOS/UEFI), t 0 makes timeout immediate
shutdown /r /fw /t 0

Setup

# Install Terminal-Icons module for Oh My Posh
Install-Module -Name Terminal-Icons -Repository PSGallery

Check Disks

# System File Checker
sfc /scannow

# Deployment Image Servicing and Management
DISM /Online /Cleanup-Image /RestoreHealth

# Locate bad sectors on disk and recover them.
chkdsk C: /r

# Fix file system errors
chkdsk C: /f

# Check disk
# Check NVIDIA driver (if installed)
nvidia-smi

File Management

# Change directory
Set-Location -Path "C:\Path\To\Directory"

# Clear screen
Clear-Host

# Open File Explorer
Start-Process explorer

# Hide folder
Set-ItemProperty -Path "C:\Path\To\Folder" -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)

# Unhide folder
Set-ItemProperty -Path "C:\Path\To\Folder" -Name Attributes -Value ([System.IO.FileAttributes]::Normal)

# Copy output to clipboard
Get-Command | Set-Clipboard

# Get help for a command
Get-Help Get-Command

History

# Get command history
Get-History

# Save history to a file
Get-Content (Get-PSReadlineOption).HistorySavePath | Out-File -FilePath "pwsh_history.txt"

Monitoring

# Get running processes
Get-Process

# Get system performance counters (CPU, memory)
Get-Counter -Counter "\Processor(_Total)\% Processor Time", "\Memory\% Committed Bytes In Use"

# Get disk usage
Get-WmiObject -Class Win32_LogicalDisk | Select-Object Size, FreeSpace

# Get event logs
Get-EventLog -LogName System -Newest 10

Networking

# Show Wi-Fi profiles
netsh wlan show profiles

# Show Wi-Fi profile with password
netsh wlan show profile name="ProfileName" key=clear

# Get IP address
Resolve-DnsName myip.opendns.com -Server resolver1.opendns.com

# Get network adapters
Get-NetAdapter

# Test connection
Test-Connection -ComputerName google.com

# Get IP configuration
Get-NetIPConfiguration

Permissions

# Get ACL for a file/folder
Get-Acl -Path "C:\Path\To\File"

# Set permissions (example: grant full control to user)
$acl = Get-Acl "C:\Path\To\File"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("UserName", "FullControl", "Allow")
$acl.SetAccessRule($accessRule)
Set-Acl -Path "C:\Path\To\File" -AclObject $acl

# Take ownership
takeown /f "C:\Path\To\File" /r /d y

Processes

# List all processes
Get-Process

# Stop a process
Stop-Process -Name "ProcessName"

# Start a process
Start-Process -FilePath "notepad.exe"

# Get process details
Get-Process -Name "explorer" | Select-Object *

Recall

Go to Local Group Policy Editor > User > Administrative Templates > Windows Components > Windows AI
Turn on to turn off Recall Snapshots

# Check if Recall is running
DISM /Online /Get-FeatureInfo /FeatureName:Recall

# Disable Recall
DISM /Online /Disable-Feature /FeatureName:Recall

# Enable Recall
DISM /Online /Enable-Feature /FeatureName:Recall

Scan

# Update antivirus signatures
Update-MpSignature

# Scan for viruses (full scan)
Start-MpScan -ScanType FullScan

# System File Checker
sfc /scannow

Security

# Get Windows Defender status
Get-MpComputerStatus

# Encrypt folder (using cipher)
cipher /E "C:\Path\To\Folder"

# Wipe free space
cipher /W:"C:\Path\To\Directory"

# Enable BitLocker
Enable-BitLocker -MountPoint "C:" -EncryptionMethod Aes256 -UsedSpaceOnly -RecoveryPasswordProtector

Software

# List installed programs
Get-WmiObject -Class Win32_Product | Select-Object Name, Version

# Uninstall a program
Get-WmiObject -Class Win32_Product -Filter "Name='ProgramName'" | ForEach-Object { $_.Uninstall() }

# Install a package (requires PackageManagement)
Install-Package -Name "PackageName" -ProviderName PowerShellGet

System

# Get computer information
Get-ComputerInfo

# Restart computer
Restart-Computer

# Shutdown computer
Stop-Computer

# Remote shutdown
Stop-Computer -ComputerName "RemotePC" -Force

Updates

# Check for Windows updates (requires PSWindowsUpdate module)
Get-WindowsUpdate

# Install Windows updates
Install-WindowsUpdate

# Get update history
Get-WUHistory

Users

# List local users
Get-LocalUser

# Create a new user
New-LocalUser -Name "NewUser" -Password (ConvertTo-SecureString "Password" -AsPlainText -Force)

# Add user to administrators group
Add-LocalGroupMember -Group "Administrators" -Member "NewUser"

# Change password
Set-LocalUser -Name "UserName" -Password (ConvertTo-SecureString "NewPassword" -AsPlainText -Force)

Virtualization

# List virtual machines (Hyper-V)
Get-VM

# Start a VM
Start-VM -Name "VMName"

# Stop a VM
Stop-VM -Name "VMName"

# Create a new VM
New-VM -Name "NewVM" -MemoryStartupBytes 1GB -NewVHDPath "C:\VMs\NewVM.vhdx" -NewVHDSizeBytes 20GB

WSL

# Set default WSL version
wsl --set-default-version 2

# List WSL distributions and versions
wsl -l -v

# List WSL distributions
wsl -l -q

# Launch a distro
wsl -d Ubuntu

# Terminate a distro
wsl -t Ubuntu

# Install WSL distro from Microsoft Store
wsl --install -d Ubuntu

# Import distro from tar file
wsl --import NixOS "C:\WSL\NixOS" "C:\Downloads\nixos-wsl.tar.gz" --version 2

# Unregister (delete) a distro
wsl --unregister NixOS