Created
September 27, 2023 12:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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