挺簡單的,Citrix帶了PowerShell子產品,雖然用起來有些莫名其妙的報錯……
這次場景需求是每天定時結束掉除了某個使用者之外的其他使用者打開的XASession,logoff+SessionID沒法判斷使用者名。一查powershell子產品果然有Snapin。
腳本如下:
Add-PSSnapin "Citrix.XenApp.Commands"
Get-XASession | where {$_.AccountName -ne "Domain\username"} | Stop-XASession
get-XASession自帶了一些限制參數,比如-serverName指定伺服器-BrowserName指定應用的名字。