Posts RSS Comments RSS 117 Posts and 170 Comments till now

Looking for interesting Citrix Problems

I am working on some blog entries and content for Citrix CDN and was curious what you guys thought.

If you have time, please leave some comments on problems or suggestions of things you would like to see. Specifically I am looking for some “real” world scenarios that I can present and provide solutions for.

Get-CitrixApplication (Playing Around Series)

Here is a quick demo of getting a Citrix Application and playing with its properties.

Best Viewed Full Screen
Get the Flash Player to see this player.

Demo File

  1. #
  2. # First we need to create the MFCOM Object
  3. #
  4. $mfapp = new-object -com MetaFrameCom.MetaFrameApplication
  5. #
  6. # To initialize we need to pass the app we want to accesss
  7. #
  8. $mfapp.Initialize(3,"Applications\Powershell")
  9. #
  10. # With Applications we need to load the data
  11. #
  12. $mfapp.loaddata(1)
  13. #
  14. # Lets see what we have
  15. #
  16. $mfapp | Get-Member -type Properties
  17. #
  18. # Lets look at Users and Groups
  19. #
  20. $mfapp | select Users,Groups
  21. #
  22. # How bout Servers
  23. #
  24. $mfapp.Servers | Select ServerName
  25. #
  26. # Sessions?
  27. #
  28. $mfApp.Sessions | ft SessionID,AppName,ClientAddress,ClientHRes,ClientVRes -auto

Get-CitrixFarm (Playing Around Series)

I wanted to show how EASY it is to play with Citrix MFCom so here is a little video.

I also want to note how most of the properties (like Servers,Applications,Zones) all return objects that have their own properties and methods. So you could very easily have these lines in your profile and always have everything just sitting there waiting to be used.

  1. $farm = New-Object -Com ‘MetaframeCOM.MetaFrameFarm’
  2. $farm.Initialize(1)
  3. Write-Host "Loaded Farm Info from $($farm.FarmName)

Best Viewed Full Screen
Get the Flash Player to see this player.

Demo File

  1. # Get Citrix Farm Object
  2. #
  3. $farm = New-Object -Com ‘MetaframeCOM.MetaFrameFarm’
  4. #
  5. # Initialize Farm
  6. #
  7. $farm.Initialize(1)
  8. #
  9. # Now that we have are farm. Lets make sure we have the one we want by Getting the FarmName
  10. $Farm.FarmName
  11. #
  12. # Lets see what we have to play with
  13. #
  14. $farm | Get-Member -type Properties
  15. #
  16. #
  17. # We have the Farm we want. Some of the Info we want is Admins. So lets Start there
  18. #
  19. $farm.Admins
  20. #
  21. # To View just a list
  22. #
  23. $farm.Admins | Select FriendlyName
  24. #
  25. # Lets see what Applications we have
  26. #
  27. $farm.Applications | ft BrowserName,ParentFolderDN
  28. #
  29. # To View the Servers
  30. #
  31. $farm.Servers | ft ServerName,IPAddress,SessionCount
  32. #
  33. # How bout Sessions?
  34. $farm.Sessions
  35. #
  36. # Lets look at Print Drivers we Have installed
  37. #
  38. $farm.Drivers
  39. #
  40. # If you have multiple Zones you can get the Names Servers and DataCollector for the Zone
  41. $farm.Zones
  42. #

Get-CitrixServer (Playing Around Series)

This is a quick run through a MFCOm Citrix Server Object

Best Viewed Full Screen
Get the Flash Player to see this player.

Demo File

  1. #
  2. # We start by creating a Server Object
  3. #
  4. $mfsrv = New-Object -ComObject MetaFrameCOM.MetaFrameServer
  5. #
  6. # Initializing Server
  7. #
  8. $mfsrv.Initialize(6,$ENV:ComputerName)
  9. #
  10. # Now we have are server… Lets see what we have to play with
  11. #
  12. $mfsrv | Get-Member -type Properties
  13. #
  14. # Lets start by looking at the current sessions on the server
  15. #
  16. $mfsrv.Sessions | ft SessionID,AppName,ClientAddress,ClientHRes,ClientVRes -auto
  17. #
  18. # What about what Zone it is in?
  19. #
  20. $mfsrv.ZoneName
  21. #
  22. # Printers?
  23. #
  24. $mfsrv.Printers
  25. #
  26. # Lets see what Processes are running
  27. #
  28. $mfsrv.Processes | ft SessionID,ProcessID,UserName,ProcessState -auto
  29. #
  30. # A common task is Server Load
  31. #
  32. $mfsrv.WinServerObject.ServerLoad
  33. #
  34. # Last (and perhaps most important) What applications?
  35. #
  36. $mfsrv.Applications | ft BrowserName,ParentFolderDN

Citrix License Info (using WMI)

I had several questions about this so I decided I should figure it out and Post. It was surprisingly simple. All I needed was the WMI provider and from there it was cake. If you’re curious how I figured out the WMI namespace I used WMI Explorer from MoW [CLICK HERE To Read about it].

The Output will look like this
Citrix License Script Ouput

Here is the Code

  1. # Get-CitrixLicensing
  2. Param($LicenseServer)
  3. $licensePool = gwmi -class "Citrix_GT_License_Pool" -Namespace "ROOT\CitrixLicensing" -comp $LicenseServer
  4. $licensePool | Select-Object @{n="Product";e={$_.PLD}},
  5.                             @{n="Model";e={"Server"}},  
  6.                             @{n="Type";e={$_.LicenseType}},
  7.                             @{n="Installed";e={$_.Count}},
  8.                             @{n="In Use";e={$_.InUseCount}},
  9.                             @{n="Available";e={$_.PooledAvailable}},
  10.                             @{n="% in use";e={($_.InUseCount/$_.Count)*100}}

Citrix and Powershell Webinar

For those of you that use Citrix Presentation Server you will want to watch this. I maybe a little bias, but I loved it :)
http://community.citrix.com/display/~vishalg/2008/04/30/PowerShell+and+Citrix+MFCOM+recorded+Webinar+and+Powerpoint+slide+deck

Powershell and MFCom (Citrix takes more steps)

Vishal Ganeriwala is hosting a webinar on the 29th of April on Powershell and MFCom. This is just another example of Citrix actively embracing Powershell.

http://community.citrix.com/blogs/citrite/vishalg/2008/04/21/Free+Managing+Citrix+Servers+via+PowerShell+and+MFCOM+webinar

It will cover some basic Powershell for those who do not have much XP with Powershell.
- What is an Object
- Properties
- Methods
- New-Object (-ComObject)

It will also cover how to create a Citrix Farm Object in Powershell and some of the interactive nature of Powershell
- Getting Farm Properties
- Getting Applications
- Getting Servers
- Getting Sessions

Example
- Get Current Sessions Client Resolution

Citrix Script Repo (aka Exchange)

I was recently directed to a new website (for me at least) that contains a repository of Citrix related scripts. There are some pretty useful scripts posted (and I started adding some Powershell ones.) You should check it out

Script Exchange
http://community.citrix.com/display/cdn/Script+Exchange

I would also recommend RSS’ing Vishal blog (Dev at Citrix.) He has a passion for Powershell and I hope to see some awesome things from him in the future.

Vishal Ganeriwala’s Blog
http://community.citrix.com/blogs/citrite/vishalg/

Get-CitrixApplication.ps1 (Citrix Top 10)

This script returns Citrix Application Objects.
- With no -AppName passed it will return All application Objects
- With -AppName it will return all apps that match (regex.)

  1. # Get-CitrixApplication.ps1
  2. # Brandon Shell [MVP]
  3. # www.bsonposh.com
  4. # Returns Citrix Application Objects for AppName passed or RegEx
  5. Param($AppName=".*",$server=$env:ComputerName)
  6. $type = [system.Type]::GetTypeFromProgID("MetaframeCOM.MetaFrameFarm",$server)
  7. $farm = [system.Activator]::CreateInstance($type)
  8. $farm.Initialize(1)
  9. $farm.Applications | ?{($_.AppName -match $AppName) -or ($_.BrowserName -match $AppName)}

Set-CitrixServerLogon.ps1 (Citrix Top 10)

Here is a useful little script. This Creates a MFCom Server Object and disables or Enables Logons for that Server.

  1. # Set-CitrixServerLogon.ps1
  2. # Brandon Shell [MVP]
  3. # www.bsonposh.com
  4. # Sets the Server to Enable or Disable Logons
  5. Param($Server,[switch]$enable,[switch]$disable,[switch]$help)
  6. function HelpMe{
  7.     Write-Host
  8.     Write-Host " Set-CitrixServerLogon.ps1:" -fore Green
  9.     Write-Host "   Sets the Server to Enable or Disable Logons"
  10.     Write-Host
  11.     Write-Host " Parameters:" -fore Green
  12.     Write-Host "   -Server                  : Optional. Server to Set Logon"
  13.     Write-Host "   -Enable                  : Optional. Checks Hours of Idle Time (Default)"
  14.     Write-Host "   -Disable                 : Optional. Checks Minutes of Idle Time"
  15.     Write-Host "   -Help                    : Optional. Displays This"
  16.     Write-Host
  17.     Write-Host " Examples:" -fore Green
  18.     Write-Host "   To disable the Logon for a Server" -fore White
  19.     Write-Host "     Set-CitrixServerLogon.ps1 -server <serverName> -Disable" -fore Yellow
  20.     Write-Host
  21. }
  22.  
  23. if(!$Server -or $help){helpme;Write-Host;return}
  24.  
  25. Write-Host
  26.  
  27. Write-Host " Getting Server [$Server]"
  28. $mfsrv = New-Object -ComObject MetaFrameCOM.MetaFrameServer
  29.  
  30. Write-Host " - Initializing Server"
  31. $mfsrv.Initialize(6,$Server)
  32.  
  33. if($enable)
  34. {
  35.     Write-Host " - Setting to EnableLogon = 1"
  36.     $mfSrv.WinServerObject.EnableLogon = 1
  37. }
  38. if($disable)
  39. {
  40.     Write-Host " - Setting to EnableLogon = 0"
  41.     $mfSrv.WinServerObject.EnableLogon = 0
  42. }
  43.  
  44. Write-Host " - Server [$($mfSrv.ServerName)] is set to [$($mfSrv.WinServerObject.EnableLogon)] for EnableLogon"
  45.  
  46. Write-Host

Another option would be to remove the Apps from the Server all together.

  1. # Unpublish-CitrixServer.ps1
  2. # Brandon Shell [MVP]
  3. # www.bsonposh.com
  4. # Removes all App from Server
  5. Param($Server)
  6. $mfsrv = New-Object -ComObject MetaFrameCOM.MetaFrameServer
  7. $mfsrv.Initialize(6,$Server.ToUpper())
  8. $mfsrv | foreach{$_.Applications} | foreach{$_.LoadData(1);$_.RemoveServer($Server.ToUpper());$_.SaveData()}

Next »