Skip to content

Instantly share code, notes, and snippets.

@prograhammer
Last active December 26, 2019 18:13
Show Gist options
  • Save prograhammer/cfe97697419d0b5b19ed to your computer and use it in GitHub Desktop.
Save prograhammer/cfe97697419d0b5b19ed to your computer and use it in GitHub Desktop.
Windows PowerShell cheatsheet

Windows PowerShell cheatsheet

View version of PowerShell
$PSVersionTable.PSVersion
Update PowerShell 2 to PowerShell 3.0 (Windows 7)
// In cmd prompt:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin cinst powershell
Clear contents of a file
Clear-Content C:\file-name-here
Equivalent to Linux "tail" command
// Will tail last 3 lines of file given:
Get-Content file-name-here -Tail 3
Equivalent to chmod 777 -R
// The '/t' is for recursive
cacls some_folder_here /t /e /g everyone:f

// New way
// The ':r' is to remove previous permissions
icacls some_folder_here /grant:r Everyone:F /t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment