1

I am trying to send a message to XenApp users via Powershell cmdlet send-xasessionmessage. The environment contains approx. 100 servers with 1000 active sessions. The script is very slow. When I test on a single server, it works fine. but seems to just hang when I input 100 servers. Do I need to use jobs.. or something else.. Please suggest,

user167153
  • 13
  • 3

1 Answers1

1

I am assuming your script is already written. If so, and it's still slow, take a look at Powershell Workflows. This will take some re-writing of your script (best to make a copy and work from that!).

While this will not speed up individual requests, at least your main thread will not be waiting (and blocking) your other requests (so you will see an overall speed-up). The best part is that Workflows are built-in to Powershell (since V3.0)

Specifically look at the Foreach –parallel directive, which is only available within the Workflow {} block.

Joseph Kern
  • 9,809
  • 3
  • 31
  • 55
  • param([string]$msg, [string]$title) if ( (Get-PSSnapin -Name Citrix.* -ErrorAction SilentlyContinue) -eq $null ) { Add-PsSnapin Citrix* } $serverlist = gc .\list1.txt foreach ($server in $serverlist) { $sessionidpool = get-xasession -servername $server foreach ($y in $sessionidpool) { if (($y.state -eq "active")) { Send-XASessionMessage -SessionId $y.sessionid -ServerName $server -messagebody $msg -MessageTitle $title } } } – user167153 Dec 28 '15 at 15:44
  • 2
    Well I am not going to do it for you ... – Joseph Kern Dec 28 '15 at 15:45
  • do I need powershell v3.0 on all servers.. or just one server which would run the script – user167153 Dec 28 '15 at 16:20
  • Just one server. – Joseph Kern Dec 29 '15 at 05:30