Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Created September 27, 2023 12:42
Show Gist options
  • Save jpluimers/742137f265bf8df6b66709d14f22ccca to your computer and use it in GitHub Desktop.
Save jpluimers/742137f265bf8df6b66709d14f22ccca to your computer and use it in GitHub Desktop.
PowerShell RDP session side test script from https://twitter.com/awakecoding/status/1706774232808701978
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public struct LASTINPUTINFO {
public uint cbSize;
public uint dwTime;
}
public class User32 {
[DllImport("user32.dll", SetLastError = false)]
public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
}
"@ -Language CSharp
1..100 | % {
Start-Sleep 1
$lii = New-Object LASTINPUTINFO
$lii.cbSize = [System.Runtime.InteropServices.Marshal]::SizeOf($lii)
[void][User32]::GetLastInputInfo([ref]$lii)
$LastInputInfoTine = $lii.dwTime
Write-Host "LastInputInfoTime: $LastInputInfoTime"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment