PowerShell/Scripts/lock-desktop.ps1

22 lines
423 B
PowerShell
Raw Normal View History

2022-09-11 11:57:15 +02:00
<#
2022-06-09 16:12:40 +02:00
.SYNOPSIS
Locks the desktop
.DESCRIPTION
This PowerShell script locks the local computer desktop immediately.
.EXAMPLE
2023-08-06 21:35:36 +02:00
PS> ./lock-desktop.ps1
2022-06-09 16:12:40 +02:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
"Bye bye."
rundll32.exe user32.dll,LockWorkStation
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
2023-08-06 21:35:36 +02:00
}