PowerShell CheatSheet – CMD > PS

Here’s some common and usefull CMD to PS equivalents

MS-DOS commandPowerShell EquivalentExplanation
xxx /?Get-Help xxx –fullDisplays the help for the ‘xxx’ command
cacls xxx /E /G user:F$ACL = Get-Acl xxx
$TempACL = New-Object SSAF1
$ACL.SetAccessRule($TempACL)
Set-Acl XXX $Acl
Modifys Access Control Lists (ACLs) for the ‘xxx’ file
cdGet-LocationDisplays the name of the current directory
cd xxxSet-Location xxxChanges the current directory for the ‘xxx’ directory
cd /d x:\xxxSet-Location x:\xxxChanges current drive in addition to changing current directory (‘x:\xxx’)
copy xxx PATHCopy-Item xxx PATHCopies the ‘xxx’ files to another location (‘PATH’)
clsClear-HostClears the screen
del xxx yyyRemove-Item xxx yyyDeletes the ‘xxx’ and ‘yyy’ files
del /f /s /p xxx yyyRemove-Item xxx yyy –Force –Recurse -ConfirmDeletes the ‘xxx’ and ‘yyy’ files from all subdirectories, even if it’s read-only files. Ask for confirmation for each file
dirGet-ChildItemDisplays a list of files and subdirectories in a directory
dir /sGet-ChildItem -RecurseDisplays files in specified directory and all subdirectories
dir /adGet-ChildItem | Where {$_.PSIsContainer}Displays files with specified attributes, directories only
dir /a:-dGet-ChildItem | Where {!($_.PSIsContainer)}Displays files with specified attributes, files only
fc file1 file2Compare-Object $(Get-Content File1) $(Get-Content File2)Compares two files and displays the differences between them
find “xxx” yyy /NSelect-String -Pattern xxx -Path yyySearch for the ‘xxx’ string in the ‘yyy’ file and display the line(s) number(s) if found
helpGet-CommandGets the available commands/cmdlets
hostname$env:computernameDisplays the computer’s hostname
net shareGet-WmiObject Win32_ShareGets the current network and administrative shares
net timeGet-DateGets the current date and time
net startGet-Service | Where {$_.Status -eq “Running”}Displays the list of running services
net start xxxStart-Service xxxStarts the ‘xxx’ service
ren xxx yyyRename-Item xxx yyyRename a file
setGet-ChildItem env:Displays CMD environment variables
set x=Clear-Item $xDeletes the contents of the ‘x’/’$x’ variable
set x=value$x=valueAffect ‘value’ to the ‘x’/’$x’ variable
start xxxInvoke-Item xxxInvoke the (provider-specific) default action on the ‘xxx’ item
tasklistGet-ProcessGets the processes that are running on the local computer or a remote computer
tasklist /FI “PID eq xxx”Get-Process –Id xxxGets the process info with Process Id xxx
tasklist /S \\XXXGet-Process –ComputerName XXXGets the processes that are running on the remote computer XXX

To Be Enriched…


1 SSAF: System.Security.AccessControl.FileSystemAccessRule(“user”,”FullControl”,”Allow”)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top