prograhammer
7/28/2014 - 3:59 PM

Windows PowerShell cheatsheet

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