Powershell Commands Cheat Sheet



  1. Powershell Commands Cheat Sheet Alias
  2. Cmd Commands Windows 10 Pdf
  3. Powershell Cmdlets List Cheat Sheet
  4. Powershell Command Cheat Sheet Pdf
  5. Powershell Network Commands Cheat Sheet
  6. Unix Commands Cheat Sheet Pdf Download Free

Around 4 years ago I wrote a blog post about how to Replace netsh with Windows PowerShell which includes basic powershell networking cmdlets. After working with Microsoft Azure, Nano Server and Containers, PowerShell together with networking becomes more and more important. I created this little cheat sheet so it becomes easy for people to get started. Basic Networking PowerShell cmdlets Get. This page contains a list of PowerShell snippets and cmdlets for penetration testing in pure PowerShell without using any additional modules. These cmdlets are useful in restricted environments where command line utilities such as net.exe, ipconfig.exe, netstat.exe, findstr.exe and others are blocked and our ability to introduce arbitrary code into the environment is limited. 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.

I have become a big fan of PowerShell Remoting. I find my self using it for both penetration testing and standard management tasks. Slack for students. In this blog I’ll share a basic PowerShell Remoting cheatsheet so you can too.

Introduction to PowerShell Remoting

PowerShell Remoting is essentially a native Windows remote command execution feature that’s build on top of the Windows Remote Management (WinRM) protocol. Based on my super Google results, WinRM is supported by Windows Vista with Service Pack 1 or later, Windows 7, Windows Server 2008, and Windows Server 2012.

Enabling PowerShell Remoting

Before we get started let’s make sure PowerShell Remoting is all setup on your system.

1. In a PowerShell console running as administrator enable PowerShell Remoting.

This should be enough, but if you have to troubleshoot you can use the commands below.

2. Make sure the WinRM service is setup to start automatically.

3. Set all remote hosts to trusted. Note: You may want to unset this later.

Powershell Commands Cheat Sheet Alias

Executing Remote Commands with PowerShell Remoting

Now we can play around a little. There’s a great blog from a while back that provides a nice overview of PowerShell Remoting at http://blogs.technet.com/b/heyscriptingguy/archive/2009/10/29/hey-scripting-guy-october-29-2009.aspx. It’s definitely on my recommended reading list, but I’ll expand on the examples a little.

Executing a Single Command on a Remote System

The “Invoke-Command” command can be used to run commands on remote systems. It can run as the current user or using alternative credentials from a non domain system. Examples below.

If the ActiveDirectory PowerShell module is installed it’s possible to execute commands on many systems very quickly using the pipeline. Below is a basic example.

Sometimes it’s nice to run scripts stored locally on your system against remote systems. Below are a few basic examples.

Also, if your dynamically generating commands or functions being passed to remote systems you can use invoke-expression through invoke-command as shown below.

Establishing an Interactive PowerShell Console on a Remote System

An interactive PowerShell console can be obtained on a remote system using the “Enter-PsSession” command. It feels a little like SSH. Similar to “Invoke-Command”, “Enter-PsSession” can be run as the current user or using alternative credentials from a non domain system. Examples below.

Sheet

If you want out of the PowerShell session the “Exit-PsSession” command can be used.

Creating Background Sessions

There is another cool feature of PowerShell Remoting that allows users to create background sessions using the “New-PsSession” command. Background sessions can come in handy if you want to execute multiple commands against many systems. Similar to the other commands, the “New-PsSession” command can run as the current user or using alternative credentials from a non domain system. Examples below.

Clear ram in windows 10

If the ActiveDirectory PowerShell module is installed it’s possible to create background sessions for many systems at a time (However, this can be done in many ways). Below is a command example showing how to create background sessions for all of the domain systems. The example shows how to do this from a non domain system using alternative domain credentials.

Commands

Listing Background Sessions

Once a few sessions have been established the “Get-PsSession” command can be used to view them.

Interacting with Background Sessions

The first time I used this feature I felt like I was working with Metasploit sessions, but these sessions are a little more stable. Below is an example showing how to interact with an active session using the session id.

To exit the session use the “Exit-PsSession” command. This will send the session into the background again.

Executing Commands through Background Sessions

If your goal is to execute a command on all active sessions the “Invoke-Command” and “Get-PsSession” commands can be used together. Below is an example.

Cmd Commands Windows 10 Pdf

Removing Background Sessions

Finally, to remove all of your active sessions the “Disconnect-PsSession” command can be used as shown below.

Wrap Up

Powershell Cmdlets List Cheat Sheet

Naturally PowerShell Remoting offers a lot of options for both administrators and penetration testers. Regardless of your use case I think it boils down to this:

Powershell Command Cheat Sheet Pdf

Powershell commands list cheat sheet
  • Use “Invoke-Command” if you’re only going to run one command against a system
  • Use “Enter-PSSession” if you want to interact with a single system
  • Use PowerShell sessions when you’re going to run multiple commands on multiple systems

Powershell Network Commands Cheat Sheet

Hopefully this cheatsheet will be useful. Have fun and hack responsibly.

Unix Commands Cheat Sheet Pdf Download Free

References