Wednesday, June 8, 2011

Powershell cheatsheet

Useful powershell commands. Will update that list if i find something interesting.

tail -n 10 {filename}
get-content {filename} | select -last 10
gc {filename} | select -last 10
tail -f {filename}
get-content {filename} -wait
gc {filename} -wait
hostname
[System.Net.Dns]::GetHostName()

2 comments:

  1. I hope that powershell has something like 'alias' :)

    ReplyDelete
  2. Sure. You can type something like this:


    Set-Alias hostname [System.Net.Dns]::GetHostName()


    And use it during the session. Or you can add this line to Microsoft.PowerShell_profile.ps1 in your powershell configuration directory and it will be loaded every time you open powershell. This is analogue of .bashrc in linux.

    ReplyDelete