Operation | cmd | PowerShell |
Get a simple directory listing |
dir |
get-childitem alias: dir |
Get a recursive directory listing |
dir /s |
get-childitem -recurse alias: dir -r |
Get a wide directory list |
dir /w |
dir | format-wide alias: dir | fw |
List built-in commands |
help |
get-command alias: help |
Copy a file |
copy foo.txt bar.txt |
copy-item foo.txt bar.txt alias: copy foo.txt bar.txt |
Move a file |
move foo.txt c:\ |
move-item foo.txt d:\ alias: move foo.txt d:\ |
Rename a file |
ren foo.txt bar.txt |
rename-item foo.txt bar.txt alias: ren foo.txt bar.txt |
Batch rename |
ren *.one *.two |
dir *.pdf | rename -newname {$_.name -rep ".one",".two"} |
Set the current directory to d:\ |
d: cd \ |
set-location d:\ alias: cd d:\ |
Clear the screen |
cls |
clear-host alias: cls |
List only directories |
dir /ad |
dir | where { $_.MshIsContainer } |
Directory list, sorted by date |
dir /od |
dir | sort-object LastWriteTime |
Directory list, sorted by date, descending order |
dir /o-d |
dir | sort-object LastWriteTime -desc |
Show the current directory |
cd |
get-location alias: pwd |
See a command’s help |
dir /? |
get-help get-command or: get-help get-command -detailed or: get-help get-command -full or: dir -? |
List environment variables |
set |
dir env: |
Delete a file |
del foo.txt |
remove-item foo.txt alias: del foo.txt |
Find all *.txt files |
dir /s *.txt |
get-childitem -recurse -include *.txt alias: dir -r -i *.txt |
Find all *.txt files containing a particular string |
findstr "foo" *.txt |
dir *.txt | select-string "foo" |
Show a list of services |
net start |
get-service |
Start a service |
net start MyService |
start-service MyService |
Stop a service |
net stop MyService |
stop-service MyService |
Show network shares |
net share |
gwmi Win32_Share |
Show a list of running processes |
tasklist |
get-process alias: ps |
Kill all notepad.exe processes |
taskkill /im notepad.exe /f |
ps notepad | kill |
nice and compact. not easy to save or print. next.