Bash to PowerShell Cheat Sheet. Posted by 2 years ago. Bash to PowerShell Cheat Sheet. I am pretty comfortable with Bash and want to do. By the way, PowerShell has been designed to be user-friendly, even old-school-Unix-shell-user-friendly, so there are built-in aliases for popular Linux/bash commands which are pointing to the actual cmdlet. For example, bash users can still let their muscle memory type pwd, because it is an alias to the cmdlet Get-Location. Image: Microsoft. PowerShell was developed more than 10 years ago by Microsoft to expand the power of its command line interface (CLI) by coupling it with a management framework that is used to manage local and remote Windows, macOS, and Linux systems.
By Xah Lee. Date: . Last updated: .
This pages shows the equivalent of PowerShell for common unix commands related to text processing.
Simple Commands
The following bash commands have PowerShell alias. (but the options may not be the same)
•
cd
• pwd
• ls
• pushd
• popd
• cp
• rm
• rmdir
• mv
• cat
• echo
• set
• ps
• kill
• clear
• man
New File
New Directory
Copy Directory
find program
Print File Content
Print First 50 Lines of File
Print Last 50 Lines of File
Join Files
unzip
List Files by File Name Extension
List Backup Files
List Directories
List Files Not Directory
List Empty Files
List Empty Directories
2021-03-20 haven't studied yet which is more proper.
List File Creation Time
delete file
List Files that Contains Search Text
Compare Files
diff, sort, get column etc
empty trash
Redirect
Note that, by default, the PowerShell redirect operator '>' creates files with little endian utf-16 encoding, and lines are hard-wrapped at 80 chars, and line ending uses Windows convention of 'rn' (ascii 13 and 10).
On unixes, the conventional file encoding is utf-8, and lines are not hard-wrapped (sometimes truncated (deleted) silently), and line ending uses 'n' (ascii 10).
To create unix style output, use out-file, like this:
However, the line ending used is still 'rn'. To create unix line ending of just 'n', use:
However, the end of the file will still contain a 'r'.
thanks to Jeffrey Snover of Microsoft for helping on about 10 of the items. (Jeffrey's the inventor of PowerShell)
If you have a question, put $5 at patreon and message me.
General System Management and Information Gathering
I’ll admit the struggle of learning PowerShell can be learning the small nuances that differ from other languages. I hope this list helps, feel free to bookmark, or shoot me an email with your requests/revisions. I’ll be updating this consistently.
- Get local Computer Info:
- Output Command(s) to File
- List Updates/Hotfixes
- Shutdown local Computer
- Shutdown Computer alternative
- List a files Properties(Last Write Time, etc)
- Add a new User
Process & Management
- Start a Process
- Stop a Process
- Get Running Processes
- Restart a Service
- Get Running Services
![Powershell command cheat sheet pdf Powershell command cheat sheet pdf](/uploads/1/1/9/5/119519806/540268227.jpg)
File Management
- Copy: Copy-Item _
- Move: Move-Item _ _
- Delete: Remove-Item _
- Read a Files content
- Get File Permissions(Access Control)
- Output Command(s) to File
Networking Commands
Port Scans/ Network Sweeps:
- Get WAN IP
Powershell Basic Cheat Sheet
- Get LAN IPv4 Address
Set DNS server
Remote Networking:
- Enter Remote PS Session: enter-pssession (machine name)(ipv4 address?)
- Run a command on specified host
Translating Bash to Powershell (How to do bash command in PowerShell)
- What is ‘ls’ in powershell?
- pwd
Powershell Scripting Cheat Sheet
- cat in powershell