Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Convenience Scripts for Windows

ℹ️ Active development of an OOBE PWSH script project over at https://github.com/aaanh/autowin. This project does most of the below and more.

Classic right-click menu Windows 11

New-Item -Path "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" -Value "" -Force
Get-Process explorer | Stop-Process

Install oh-my-posh

winget install JanDeDobbeleer.OhMyPosh -s winget 

Fish-like autosuggestion for powershell

  • Install
Install-Module PSReadLine -RequiredVersion 2.1.0
  • Init
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History

Shut down a remote PC

shutdown -r -m \\MACHINE-NAME.<domain>.<tld>

Execution Policy ⚠️

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
ExplanationBy default, the policy is set to Restricted: commands can be typed and run in the shell, but cannot run a script file. RemoteSigned is the minimal policy that allows it.

Virtualization Features ⚠️

Required for: Windows Subsytems for Linux, Hyper-V, Docker

$win_features = "HypervisorPlatform", "VirtualMachinePlatform", "Microsoft-Windows-Subsystem-Linux", "Microsoft-Hyper-V-All", "Microsoft-Hyper-V", "Microsoft-Hyper-V-Tools-All", "Microsoft-Hyper-V-Management-Powershell", "Microsoft-Hyper-V-Hypervisor", "Microsoft-Hyper-V-Services", "Microsoft-Hyper-V-Management-Clients"

ForEach ($0 in $win_features) {
  Write-Host "Now installing $0..."
  dism /online /enable-feature /featurename:$0 /All /NoRestart
}

Disable 256-character path limit ⚠️

a.k.a. Enable long path

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
ExplanationThe command is taken from Microsoft's Docs. It adds an entry to the registry (GUI accessible through regedit) which allows the long path.