Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Help

Get-Help [cmdlet][-Examples]

Get-help - return information on how to use the help system.

Get-help sort - will return information on the sort cmdlet

Get-help sort -Examples - will return examples on how to use the sort cmdlet

...

This will take the output of get-command which is currently only going to list commands that are related to the package management and pipe it into sort which then sorts it by noun and verb.

The above command could be partially done with - get get-command | findstr packagemanagement | sort noun, verb

get-command > allcommands.txt

...

Find all packages provided by chocolatey

find-package | findstr chocolatey | sort > chocolatey-packages.txt

Find all packages provided by chocolatey and save the results in a file called chocolatey-packages.txt

...

Search the file system for a particular file with a particular file name pattern

Get-ChildItem -Path .\ -file -filter *.pem -Recurse

From the current location recursively search for any files ending with .pem

List contents of an environment variable and split them out based on a delimiter

$env:path -split ';'

Run an Application in the background

Start-Process -NoNewWindow ping google.com

Or you can create a reusable shortcut function, and store it in a script file that is then on the PATH

function bg() {Start-Process -NoNewWindow @args}

Find a process listening on a port

Code Block
languagepowershell
netstat -aon | findstr ":80" | findstr "LISTENING"

OR

Code Block
Get-Process -Id (Get-NetTCPConnection -LocalPort Your_Port_Number).OwningProcess

Kill a process by its PID

Code Block
tasklist /fi "pid eq <PID>"