Get-CitrixAppServer.ps1 (Citrix Top 10)
This is pretty simple script. It is actually just an adaption from my Get-CitrixApplication.ps1 script posted at the bottom. There is a moment in time when you start thinking in terms of objects and stop thinking in terms of text output you are looking for.
This will make a huge difference in productivity and take you from constantly writing scripts to interactively getting the information you are after, but until you make the transition I will continue to provide scripts that do both
-
# Get-CitrixAppServer.ps1
-
# Brandon Shell [MVP]
-
# www.bsonposh.com
-
# Gets All the Servers for Specific App
-
Param($app)
-
$mfApp = New-Object -ComObject MetaFrameCOM.MetaFrameApplication
-
$mfApp.Initialize(3,$app)
-
$mfApp.LoadData(1)
-
$mfApp.Servers | %{$_.ServerName}
Here is the script that I use to return an Application object.
-
# Get-CitrixApplication.ps1
-
# Brandon Shell [MVP]
-
# www.bsonposh.com
-
# Gets a Citrix Application Object.
-
Param($app)
-
$mfApp = New-Object -ComObject MetaFrameCOM.MetaFrameApplication
-
$mfApp.Initialize(3,$app)
-
$mfApp.LoadData(1)
-
$mfApp
Then from the commandline I would just do this
PS> Get-CitrixApplication.ps1 “Applications\MyApp1″ | %{$_.Servers} | %{$_.ServerName}
While this looks more complicated it is more versatile and easy to change. Lets say I want current User for this app instead.
PS> Get-CitrixApplication.ps1 “Applications\MyApp1″ | %{$_.Sessions} | %{$_.UserName}
tshell :: Apr.09.2008 :: All, Citrix, Powershell, Scripting :: No Comments »
