I'm testing a program that listens for key presses on remote machines, so I need to generate them somehow, and preferably only using powershell core.
I'm getting Access Denied (win32 exception or dotnetmethod exception) when I try to use SendKeys on a remote computer via invoke-command, even though credentials are supplied to the script with admin rights and it works fine locally.
I'm running many scripts in this way and this script is the only one thats fails (and it fails the same way on all operating systems)
e.g.
$script =
{
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait($item);
}
invoke-command -computername $machine -scriptblock $script -credential $cred
SendInput looks like it might be a promising replacement but I haven't been able to find an example that works for me.