As I continue to work on my PS work flow, time has come to start building Citrix components...
I had tons of vbscripts I wrote before, so this part shouldn't be that hard... One of functions I wanted to have is Get-AppsFromFolder, which can dump published applications from specific folder.
I love this, because than you can have really, really fast enumerations if you want to retrieve published applications based on some filter (for example show me all applications in "applications/primary"). In huge enterprise environments parsing all published icons and filtering output can take ages.
In my VBScript I had line
Set rootAppFolder = theFarm.GetRootFolder(MetaFrameAppFolder)
I tried $AppFolder = $CitrixFarm.GetRootFolder(MetaFrameAppFolder). Of course it didn't work - I realized that MetaFrameAppFolder should be index here...
Well, I don't really like $AppFolder = $CitrixFarm.GetRootFolder(12), so I started to write constants. Well, I wrote 2-3 of them and then tried Google :)
I found Citrix MFCom Enums from Brandon Shell and it saved me tons of time - however because I want to implement user-friendly functions and don't want to spend hours and hours by implementing special checks if arguments are correct, I decided that I would rather create custom enumerations.
Then for example if my script requires color as parameter, I can just use simple function:
and don't need to care about any other code - only accepted values from now on are MF.Color enums...
For example I use following to add all supported color values:
New-Enum MF.Color Unknown 16 256 64K 16M
If you would try to use Test-Color with unsupported value, for example Red, you will get following error:
PS C:\Links\HDDs\DevHDD\WorkingProjects\S4Maintenance> Test-Color -Color Red
Test-Color : Cannot convert value "Red" to type "MF.Color" due to invalid enumeration values. Specify one of the follow
ing enumeration values and try again. The possible enumeration values are "Unknown, 16, 256, 64K, 16M".
At line:1 char:18
+ Test-Color -Color <<<< Red
As you can see, as "side effect" you get all possible enumerations... Also you can use [enum]::GetValues([MF.Color]) to get all possible values.
Right now I can't publish all enumerations I have done, but you can easily translate them from Brandon's excellent blog...