Created
November 21, 2013 10:29
-
-
Save ringe/7579356 to your computer and use it in GitHub Desktop.
Logg off all Citrix user session in PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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