Skip to content

Instantly share code, notes, and snippets.

@ringe
Created November 21, 2013 10:29
Show Gist options
  • Save ringe/7579356 to your computer and use it in GitHub Desktop.
Save ringe/7579356 to your computer and use it in GitHub Desktop.
Logg off all Citrix user session in PowerShell
$timeout = 300
$message = "Please save your work. You will be logged off in "+ $timeout/60 +" minutes"
$sessions = @()
# Collect session IDs and warn users
query session | select-string "wdica" |
%{$_ -replace " {2,27}"," "} |
foreach {$_.ToString().split(" ")[3]} |
foreach {
$sessions += $_
msg $_ /TIME:$timeout $message
}
# Wait for timeout
sleep $timeout
# Log off sessions
$sessions | foreach { logoff $_ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment