powershell command lock screen

C++
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
  }rundll32.exe user32.dll, LockWorkStation)
Source

Also in C++: