lang/ps/ NotesLearnWindowsPowershellInAMonthOfLunches


What follows is mostly command examples to illustrate things. Additional notes will be added sparingly.

There is the PowershellISE.

Powershell is CaseInsensitive but commonly things are in TitleCase like e.g. Get-SmbShare

Dir; ls; copy; cd; move; ren; mkdir; rmdir; del
type # cat contents of file
Dir | more
dir > file.txt

cd hkcu: # gets to HKEY_CURRENT_USER in registry
new-psdrive -name flibble -psprovider filesystem -root c:\users
new-psdrive -name hexvision -psprovider filesystem -root \\mymachine\myshare\subdir

net use # can use external programs as expected

$files = Get-ChildItem -Path C:\Windows -Filter "*.exe"
$files # will dump variable to terminal
$env:Path # environment variables

Get-ChildItem # ls
Set-Location # cd
Move-Item # mv
Rename-Item # mv
Remove-Item # rm
Copy-Item # cp
Get-Content # cat
New-Item # Mkdir
Get-ChildItem -recurse

Get-Service
Get-Process
Get-EventLog
New-Service

Help

Get-Help Get-ChildItem -Online
Get-Help New-SmbShare | More
Get-Help *Move*
Get-Help Get-EventLogd