Note that there are some explanatory texts on larger screens.

plurals
  1. POP/Invoke during PSSession
    primarykey
    data
    text
    <p>For some reason, P/Invoke via PSSession is not working. I have a client side script which I run from a server through a PSSession. Here's the code for the client-side script:</p> <pre><code>$signature = @" [DllImport("user32.dll")] public static extern bool BlockInput(bool fBlockIt); "@ $block = Add-Type -MemberDefinition $signature -Name DisableInput -Namespace DisableInput -PassThru $unblock = Add-Type -MemberDefinition $signature -Name EnableInput -Namespace EnableInput -PassThru $block::BlockInput($true) Start-Sleep -Seconds 10 $unblock::BlockInput($false) </code></pre> <p>I'm basically testing blocking/unblocking keyboard and mouse access, based off a walkthrough I found <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CCsQFjAA&amp;url=http://www.powershell.nu/2012/10/08/block-and-unblock-keyboard-mouse-input-using-powershell/&amp;ei=KvyfUp3XIZHsoATFvoDIBw&amp;usg=AFQjCNGB7APD7y-Cro0DCJK-HoKFUpTvgQ&amp;bvm=bv.57155469,d.cGU" rel="nofollow">here</a>. I can successfully get the script to run, and the account I'm running it with should have elevated permissions, but for some reason, the call to <code>$block::BlockInput</code> and <code>$unblock::BlockInput</code> are both returning <code>False</code>, and neither the keyboard nor the mouse are blocked.</p> <p>When I run the exact same script with the same account directly on the client machine, the script does exactly what it should - locks the keyboard and mouse for 10 seconds, and both calls to <code>BlockInput</code> return <code>True</code>. What am I doing wrong? Is it possible to P/Invoke via a PSSession?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload