Posts RSS Comments RSS 117 Posts and 170 Comments till now

Archive for April, 2008

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

CMDLet Design Suggestion

I wanted to make a case for using Task Base CMDLETs instead of methods when designing Snapins. There have been several “Vendors” that have done CMDLets for Powershell: Exchange, Citrix, VMWare, and IBM to name a few. Most have done very well here, but this is one thing I think the VMware team excelled at.

< sidebar >
As some of you may know, I have a long background in Active Directory. As an Ex-Microsoft Support Professional in the Directory Services Team and later a Rapid Response Engineer specializing in Active Directory, let’s just say I have passion for all things AD.
I was lucky enough to spend a significant amount of time with the DS team at MS responsible for the Powershell CMDLets they will release at some time in the future. While I cannot give any details I can say… OMG! I CANNOT WAIT to be able to talk about them.
< / sidebar >

Here is the basic Goal

  1. Get-Something | Filter | Change-Something | Change-SomethingElse | Save-Something

The thing to avoid: Depending on methods for object task.
Get-Something | %{$_.DoSomething()}

Here is an Example of what I mean
Lets say we have a Car Object (class). The Car object has Properties like Make, Model, Color, TireCount, Size, and Type.
We also have things we can do with a car like start , turn off, stop, turn, load, and unload.

We could approach this by creating a Car class with the set properties and methods. This may seem simpler, but it is not intuitive for your typical Admin. Your typical admin does not want to do this

  1. Get-Car | ?{$_.Type -eq "MiniVan"} | %{$_.LoadPeople()} | %{$_.Start()} | %{$_.Turn("Right")} | %{$_.Stop()} | %{$_.UnLoadPeople()}

Ideally from an Admin perspective a bunch of Task oriented CMDLets would be your best bet. Let’s assume you had these CMDLets instead of Methods:
Get-Car
New-Car
Remove-Car
Start-Car
Stop-Car
Invoke-TurnCar
Invoke-LoadCar
Invoke-UnLoadCar
Set-Car

Your admin can now do this

  1. Get-Car |  ?{$_.Type -eq "MiniVan"} | Invoke-LoadCar | Start-Car | Invoke-TurnCar -Right | Stop-Car | Invoke-UnloadCar

This reads more like a sentence than a script syntax.

www.ActiveDir.org (where cool people hang out)

At least until I showed up :)
Seriously, If you need AD assistance this is the place to go. Some of the best AD minds in the world camp that list.

These guys effectively donate their time and only ask that you respect that.

I would also suggest you do some research before you ask your question. It helps everyone out if you know what your looking for in advance.

Tell them Unknow Guy w/ Dean Sent you ;)

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

Back From the MVP Summit

Well… Just got back from a week in Redmond. It was awesome!

First I want to thank MS for putting this all together. It was a testament to their commitment to the community and desire to see their products succeed.

While this was my first MVP summit, I did hear several others comment on how this was the best one yet.

I was VERY lucky to have a seasoned MVP vet (Dean Wells) show me the ropes and introduce me to some of the (IMO) smartest technical people on the planet. These guys/gals are not only incredibly smart… but they were an absolute blast to hang out with.

I doubt they subscribe to my blog but I wanted to do a shout out and link their blogs/Sites

Dean Wells: Absolute Great Trainer/Consultant http://www.msetechnology.com
joe Richards (joeware): http://blog.joeware.net/
Joe Kaplan : http://www.joekaplan.net/
Brian Desmond: http://briandesmond.com/blog/default.aspx
Laura Hunter: http://www.shutuplaura.com/
Mr Hunter (Mark Arnold) : http://markarnold.blogspot.com/
Gil Kirkpatrick (NetPro): http://www.gilsblog.com/
Ulf B. Simon-Weidner’s: http://msmvps.com/blogs/UlfBSimonWeidner/Default.aspx
Tony Murray (founder activedir.org): www.ActiveDir.org Blog: http://www.open-a-socket.com/
Little Jimmy: http://www.jimmytheswede.blogspot.com/
Darren Mar-Elia (SDMSoftware): http://www.sdmsoftware.com/blog/
Princess Jorge!: http://blogs.dirteam.com/blogs/jorge/
Brett Shirley: http://blogs.msdn.com/brettsh/
Eric Fleischman: http://blogs.technet.com/efleis/default.aspx (currently VERY slow to post)

I can not tell you (literally I am under NDA :) ) How much I learned this past week.

What I can say is that for Powershell… the future is VERY BRIGHT!

The time with the Powershell Dev team was great. Again… can’t say much, but they have great plans.

I spent about 5hrs with the Active Directory team discussing their plans. If the AD Team can pull off what they have planned… OMG it is awesome. AD administration will never be the same.

The next version of SCVMM looks great.

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()}

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 :)

  1. # Get-CitrixAppServer.ps1
  2. # Brandon Shell [MVP]
  3. # www.bsonposh.com
  4. # Gets All the Servers for Specific App
  5. Param($app)
  6. $mfApp = New-Object -ComObject MetaFrameCOM.MetaFrameApplication
  7. $mfApp.Initialize(3,$app)
  8. $mfApp.LoadData(1)
  9. $mfApp.Servers | %{$_.ServerName}

Here is the script that I use to return an Application object.

  1. # Get-CitrixApplication.ps1
  2. # Brandon Shell [MVP]
  3. # www.bsonposh.com
  4. # Gets a Citrix Application Object.
  5. Param($app)
  6. $mfApp = New-Object -ComObject MetaFrameCOM.MetaFrameApplication
  7. $mfApp.Initialize(3,$app)
  8. $mfApp.LoadData(1)
  9. $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}

Find-CitrixUser.ps1 (Citrix Top 10)

This is another script that I can use quite often. It is a simple script that queries all the sessions and returns the ones where the User matches. I made the User a RegEx search so you could do multiple users.

Name: Find-CitrixUser.ps1
Purpose: Finds where the user(s) are and outputs session info

  1. # Find-CitrixUser.ps1
  2. # Brandon Shell [MVP]
  3. # www.bsonposh.com
  4. # Finds where the user(s) are and out puts session info
  5. Param($user=".*",[switch]$help)
  6. function HelpMe{
  7.     Write-Host
  8.     Write-Host " Find-CitrixUser.ps1:" -fore Green
  9.     Write-Host "   Finds where the user(s) are and out puts session info"
  10.     Write-Host
  11.     Write-Host " Parameters:" -fore Green
  12.     Write-Host "   -User                  : Optional. Name of the User or RegEx (Default is all users)"
  13.     Write-Host "   -Help                  : Optional. Displays This"
  14.     Write-Host
  15.     Write-Host " Examples:" -fore Green
  16.     Write-Host "   Finds User TestMe and outputs and returns ServerName,ClientAddress, and SessionID" -fore White
  17.     Write-Host "     .\Find-CitrixUser.ps1 | ft ServerName,ClientAddress,SessionID " -fore Yellow
  18.     Write-Host
  19.     Write-Host "   Finds all Users who start with ‘Sales’ and returns UserName,ServerName, and SessionID"  -fore White
  20.     Write-Host "     .\Find-CitrixUser.ps1 `"^sales`" | ft UserName,ServerName,SessionID " -fore Yellow
  21.     Write-Host
  22.     Write-Host "   To View All properties availiable." -fore White
  23.     Write-Host "     .\Find-CitrixUser.ps1 <username> | Get-Member" -fore Yellow
  24.     Write-Host
  25. }
  26.  
  27. # Check for the Help or if
  28. if($help){helpme;Write-Host;return}
  29.  
  30. # Code to Get the Farm and Initialize
  31. $farm = New-Object -com "MetaframeCOM.MetaFrameFarm"
  32. $farm.Initialize(1)
  33.  
  34. # Get the Sessions and Parse for Users who match
  35. $farm.Sessions | ?{$_.UserName -match $user}

Next »