Provide one line PowerShell script that you found useful, one script per answer please.
There is a similar question here, but this one gives only links to pages with scripts, lets answers one by one here and have a contributed list of most frequently used or most useful scripts.
List most recent version of files
ls -r -fi *.lis | sort @{expression={$_.Name}}, @{expression={$_.LastWriteTime};Descending=$true} | select Directory, Name, lastwritetime | Group-Object Name | %{$_.Group | Select -first 1}
gps programThatIsAnnoyingMe | kill
Open a file with its registered program (like
start
e.gstart foo.xls
)ii foo.xls
Retrieves and displays the paths to the system's Special Folder's
[enum]::getvalues([system.environment+specialfolder]) | foreach {"$_ maps to " + [system.Environment]::GetFolderPath($_)}
Copy Environment value to clipboard (so now u know how to use clipboard!)
$env:appdata | % { [windows.forms.clipboard]::SetText($input) }
OR
ls | clip
With SnapIns
Files between two changeset numbers in TFS
Get-TfsItemHistory <location> -Recurse -Version <label1>~<label2> | % { $(Get-TfsChangeset $_.ChangeSetID).Changes } | % { $_.Item.ServerItem } | Sort-Object -Unique
Gets queue messages with errors over all Hub servers in exchange 200
Get-ExchangeServer | ?{$_.IsHubTransportServer -eq $true} | Get-Queue | ?{$_.LastError -ne $null} | Sort-Object -Descending -Property MessageCount | ft -Property NextHopDomain,@{l="Count";e={$_.MessageCount}},@{l="Last Try";e={$_.LastRetryTime.tosting("M/dd hh:mm")}},@{l="Retry";e={$_.NextRetryTime.tostring("M/dd hh:mm")}},Status,LastError -AutoSize