Bash To Powershell Cheat Sheet



  • Miscellaneous reminders around Windows PowerShell (functions, variables,syntax, etc.) PS Fab: Windows PowerShell scripts, functions, techniques, etc. IIS related or not! A piece of my work around PowerShell and IIS (or usefull things I've found on the web).
  • PowerShell Cheat Sheet / Quick Reference. GitHub Gist: instantly share code, notes, and snippets.
  • Cheat Sheet Bash and PowerShell. File Name RegEx String Matching RegEx. String Replacement RegEx. Bash and PowerShell Quick Reference. Bash: PowerShell: Description: Scripting Basics #!/bin/bash 'shebang' as the first line of the file. Give execute permission on script file. Suggested ext:.sh.
  • Homepage: Chocolatey.org Chocolatey is a machine-level package manager and installer for software packages, built for the Windows NT platform. It is an execution engine using the NuGet packaging infrastructure and Windows PowerShell to provide an automation tool for installing software on Windows machines, designed to simplify the process from the user perspective.

History

PSReadLine records all actions in a dedicated history file that exists next to the default PowerShell history:

In the past plaintext credentials were written to that file potentially exposing secrets unintentionally. This has been fixed in PowerShell/PSReadLine #1058 which prevents lines that match password|asplaintext|token|key|secret from being written to the log.

I included the most useful MSFVenom commands in this MSFVenom cheat sheet. MSFVenom is a payload generator for Metasploit. You can generate payloads for msfconsole or meterpreter. Substitution Command Encoder cmd/perl normal Perl Command Encoder cmd/powershellbase64 excellent Powershell Base64 Command Encoder cmd/printfphpmq manual.

You can add your own filter logic like this:

Increase the number of records in your PSReadLine history with (default: 4096):

The Clear-History cmdlet can not be used to clear the history of commands. It clears only the list of previous commands that the Get-History cmdlet displays.

To delete the history of previous commands, you need to delete the file in which they are stored. The easiest way to do this is with the command:

Powershell Basic Cheat Sheet

Powershell scripting cheat sheet

You can further improve your history handling with:

Misc

Bash To Powershell Cheat Sheet

Prevent annoying beeping noises (e.g. when pressing backspace on empty line):

You can use Ctrl+L in PowerShell to clear the screen, but I miss Ctrl+D to exit the shell:

If you want pwsh to behave like linux shells, .i.e. navigate with Ctrl+a / Ctrl+e use emacs edit mode:

Bash to powershell cheat sheet download

Insert the last argument from the previous command with Alt+.:

To give you an arrow navigable list of possible completion choices run:

If you want to set multiple settings you can condense them via splatting:

Use Ctrl+Shift+P to copy the current working directory to the clipboard:

Useful handlers

Bash To Powershell Cheat Sheet Pdf

Cheat

Powershell Cheat Sheet Pdf

Taken from SamplePSReadLineProfile.ps1