Skip to main content


Showing posts from September, 2017

Useful Powershell stuff

Add a calculated property to a list of objects, along with all the other properties:
    Select *,@{Name="ExtraField;Expression={$_.SomeValue+1}}

Get a list of drives, including network drives and their UNC paths (like with "net use"):
    Get-WmiObject -Class win32_logicaldisk

Get previous session history with "get-history"
Run a previous command without pushing up 1000 times with "invoke-history"

csi = C# interactive (custom alias)

get a list of every property and value for an object:
    $whatever | Format-List
Prevent output from truncating:
    Format-Table -AutoSize -Wrap

& { blah } 1 > $null    - suppress standard output from executing "blah". More info
$var = & Do-Stuff *>&1  - redirect all output to standard output and store that in $var
& { whatever } 2>$null 3>$null - redirect error and warning streams

get-content .\somefile -Wait  - tail-like behaviour, displays additi…