Note that there are some explanatory texts on larger screens.

plurals
  1. PORemotely locking a workstation is not working, why?
    primarykey
    data
    text
    <p>So about a year ago, I discovered <a href="http://gallery.technet.microsoft.com/scriptcenter/cfbc642e-9a1e-4739-9ac5-9f462343a2f7" rel="nofollow">this PowerShell script</a>:</p> <pre><code>Function Lock-Workstation { param( $Computername, $Credential ) if(!(get-module taskscheduler)){Import-Module TaskScheduler} New-task -ComputerName $Computername -credential:$Credential | Add-TaskTrigger -In (New-TimeSpan -Seconds 30) | Add-TaskAction -Script ` { $signature = @" [DllImport("user32.dll", SetLastError = true)] public static extern bool LockWorkStation(); "@ $LockWorkStation = Add-Type -memberDefinition $signature ` -name "Win32LockWorkStation" ` -namespace Win32Functions ` -passthru $LockWorkStation::LockWorkStation() | Out-Null } | Register-ScheduledTask TestTask -ComputerName $Computername ` -credential:$Credential } </code></pre> <p>I cannot get it working. I get all kinds of weird errors. It starts with errors about not being able to find the terminating "@, and once I get that fixed it starts throwing errors in the TaskScheduler module, specifically that it cannot load the type [__ComObject] (which is used in a couple of the TaskScheduler scripts, and I can't find any documentation on it).</p> <p>I am trying to get this working in PowerShell v2.</p> <p>Anyone got any ideas?</p> <p>EDIT 1:</p> <p>So I've done some more testing, and it appears that technically it is working (there was a typo in the TaskScheduler module that was causing it to fail completely), but despite the task being scheduled on the remote workstation, the execution of that task fails, kinda. Frequently the task will "run" but with no results, despite having the credentials of the currently logged on user.</p> <p>EDIT 2: Downvotes? Really? I'm having issues, I've described the errors I am getting, and rather than offer a suggestion you downvote the question? What is this, Reddit?</p>
    singulars
    1. This table or related slice is empty.
    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