More Useful PowerShell Commands

Some more PowerShell commands I’ve found useful… Enjoy!

Get process start time

Get-Process -Id [PID] | FL StartTime

Emulate “Press Any Key”

Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Download the Latest IIS Log from a bunch of servers

foreach ($server in $serverlist) {
get-childitem -path \$serverc$iislogssite1 | 
where-object { -not $_.PSIsContainer } | 
sort-object -Property $_.CreationTime | 
select-object -last 1 | 
copy-item -Destination (join-path $path "$server-latest.log") }