20 Nov Lock-Workstation
You can do everything with PowerShell, yes as well locking your workstation with one simple function call. The function uses the API by importing the user32.dll and is being invoked to lock the workstation. Thanks to Mike Pfeiffer from TechNet for this simple but useful script. The fine thing is, it works on a local or remote session.
#Requires -Version 2.0
$sig = @"
[DllImport("user32.dll", SetLastError = true)]
public static extern bool LockWorkStation();
$LockWorkStation = Add-Type -MemberDefinition $sig -Name "Win32LockWorkStation" -Namespace Win32Functions -Passthru
$LockWorkStation::LockWorkStation() | Out-Null