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.
1.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}
2.
gps programThatIsAnnoyingMe | kill
3.Open a file with its registered program (like start
e.g start 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) }
With SnapIns
Files between two changeset numbers in TFS
Get-TfsItemHistory -Recurse -Version ~ | % { $(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