Posts RSS Comments RSS 253 Posts and 411 Comments till now

An Interactive Case for Powershell (Yet more Citrix Fun!)

I was recently in a discussion on Brian Madden Forums about listing Citrix Information and exporting to CSV. It seemed like a
perfect fit for Powershell so I converted the VBScripts to Powershell (of course taking an 85 line script to 3 lines. Convert is
hardly the correct term.)

Here is the Forum Topic

Here is my Code. There were three scripts, so I made three as well.

# Apps by Server CTXApps_by_Server_w_Users
$MF = (New-Object -com MetaFrameCOM.MetaFrameFarm)
$MF.Servers | Select-Object ServerName -expand Applications | Select-Object ServerName,AppName,DistinguishedName,
       @{n=‘Users’;e={$_.Users | %{$_.UserName}}},
       @{n=‘Groups’;e={$_.Groups | %{$_.GroupName}}} | export-Csv C:\AppsByServer.Csv -noType
# Apps with Servers
$MF = New-Object -com MetaFrameCOM.MetaFrameFarm
$MF.Applications | Select-Object AppName,DistinguishedName,
      @{n="Servers";e={$_.Servers | foreach{$_.ServerName}}} | export-Csv C:\AppsWithServer.Csv -noType
# Apps with Servers and Users CTXApps_w_Servers_w_Users
$MF = New-Object -com MetaFrameCOM.MetaFrameFarm
$MF.Applications | Select-Object AppName,DistinguishedName,
      @{n="Servers";e={$_.Servers | foreach{$_.ServerName}}},
      @{n=‘Users’;e={$_.Users | %{$_.UserName}}},
      @{n=‘Groups’;e={$_.Groups | %{$_.GroupName}}} | export-Csv C:\AppsWithServerandUsers.Csv -noType

If you notice in my three scripts they all start with the same two lines. Effectively these are one liners that could be used
interactively. I think this does a great job of showing Citrix Admins how nicely Powershell will fit in to their daily lives.
Things that use to take 100s of lines of script writing can now be done interactively at a shell.

3 Responses to “An Interactive Case for Powershell (Yet more Citrix Fun!)”

  1. on 30 Jan 2008 at 5:32 pmnicad49

    Can you explain the last part of each script? Specifically the @{n=”Servers”;…}etc. I understand that we are creating some sort of an array, but if I run it as is, I don’t get any values returned.


  2. on 17 Feb 2008 at 6:53 pmpowershellrocks

    Hi Brandon
    Can you please explain what @{n=”Servers”;e={$_.Servers | foreach{$_.ServerName}}}, ….etc does in powershell sytanx. I am new to powershell and trying to understand what you did.

  3. on 17 Feb 2008 at 9:57 pmBrandon

    That is what they call a calculated property… I explain it in detail in

Trackback this post | Feed on Comments to this post

Leave a Reply

You must be logged in to post a comment.