powershell command lock screen code example
Example 1: powershell command lock screen
rundll32.exe user32.dll, LockWorkStation)
Example 2: powershell command lock screen
if ($args[1] -is [int]) {
$nb = $args[1]
Write-Output "Locking screen in $nb seconds"
Start-Sleep -Seconds $nb
$lockscreen = $(rundll32.exe user32.dll, LockWorkStation)
$lockscreen
}