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") }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.