Skip to content

Instantly share code, notes, and snippets.

@maravedi
Last active May 4, 2016 17:58
Show Gist options
  • Save maravedi/00d98497165044e4ed87143bdb6ef2c8 to your computer and use it in GitHub Desktop.
Save maravedi/00d98497165044e4ed87143bdb6ef2c8 to your computer and use it in GitHub Desktop.
# Keep the PowerShell window on top
$signature = @"
[DllImport("user32.dll")]
public static extern bool SetWindowPos(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags);
"@
$type = Add-Type -MemberDefinition $signature -Name SetWindowPosition -Namespace SetWindowPos -Using System.Text -PassThru
$handle = (Get-Process -id $Global:PID).MainWindowHandle
$alwaysOnTop = New-Object -TypeName System.IntPtr -ArgumentList (-1)
$type::SetWindowPos($handle, $alwaysOnTop, 0, 0, 0, 0, 0x0003)
# Get the current date since the log file has the date in the filename
# Date format is: YYYY-MM-DD
$month = get-date -uformat %m
$day = get-date -uformat %d
$year = get-date -uformat %Y
$date = $year+'-'+$month+'-'+$day;
Get-Content -Path "\\server\logfile_$date.log" -Wait -Tail 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment