Using PowerShell in Your Environment
One of the cool new built-in features that is included with Windows Server 2008 is Windows PowerShell (note: Versions of Windows PowerShell are also available for Windows XP SP2, Windows Server 2003, and Windows Vista and be download from Microsoft’s website). Windows PowerShell is an admin-focused scripting language that “allows IT professionals to to more easily control system administration and accelerate automation.” Windows PowerShell has over 130 built in command line tools to administer your Windows environment.
One of the cool things about PowerShell is that you can create your own command line functions (or cmdlets) leveraging COM, WMI, etc. An infamous COM server in the Citrix world is MFCOM. Using MFCOM with PowerShell allows you to perform many of the functions your would normally do in the CMC or ASC via a command line. This allows you to add more automation to your Citrix and Terminal Services environments.
Here is an example of using MFCOM with PowerShell to export Citrix published applications to a CSV file (as seen on Dennis Verwiej’s website):
# First the known steps to connect to the mfcom and initialize the object
$c_farm = new-object -com metaframecom.metaframefarm
$c_farm.initialize(1)
# Now we read the properties of the published applications
$c_farm.applications|select-object
@{e={$_.appname};n=’appname’},
@{e={$_.groups|foreach {$_.groupname}};n=’groupname’},
@{e={$_.users|foreach{$_.username}};n=’username’},
@{e={$_.distinguishedname};n=’distinguishedname’},
@{e={$_.description};n=’description’},
@{e={$_.apptype};n=’apptype’},
@{e={$_.browsername};n=’browsername’},
@{e={$_.winappobject.enableapp};n=’enableapp’},
@{e={$_.winappobject.hidefrompnenum};n=’hidefrompnenum’},
@{e={$_.winappobject.hidefrombrowserenum};n=’hidefrombrowserenum’},
@{e={$_.winappobject.defaultencryption};n=’defaultencryption’},
@{e={$_.winappobject.defaultinitprog};n=’defaultinitprog’},
@{e={$_.winappobject.defaultworkdir};n=’defaultworkdir’},
@{e={$_.winappobject.defaultwindowwidth};n=’defaultwindowwidth’},
@{e={$_.winappobject.defaultwindowheight};n=’defaultwindowheight’},
@{e={$_.winappobject.defaultwindowcolor};n=’defaultwindowcolor’},
@{e={$_.winappobject.defaultwindowtype};n=’defaultwindowtype’},
@{e={$_.winappobject.defaultsoundtype};n=’defaultsoundtype’},
@{e={$_.winappobject.defaultwindowscale};n=’defaultwindowscale’},
@{e={$_.winappobject.desktopintegrate};n=’desktopintegrate’},
@{e={$_.winappobject.mfattributes};n=’mfattributes’},
@{e={$_.winappobject.publishingflags};n=’publishingflags’},
@{e={$_.winappobject.PNAttributes};n=’PNAttributes’},
@{e={$_.winappobject.PNFolder};n=’PNFolder’},
@{e={$_.winappobject.parentfolderDN};n=’parentfolderDN’},
@{e={$_.winappobject.AllowMultiInstancePerUser};n=’AllowMultiInstancePerUser’},
@{e={$_.winappobject.StartMenuFolder};n=’StartMenuFolder’},
@{e={$_.winappobject.PlaceUnderProgramsFolder};n=’PlaceUnderProgramsFolder’},
@{e={$_.winappobject.WaitOnPrinterCreation};n=’WaitOnPrinterCreation’}|
# The last step is to pipe this to the export-csv cmdlet
export-csv c:\citrix\Citrix_apps.csv
If you would like to learn more about Windows PowerShell, be sure to check out Microsoft’s free PowerShell course book.
For more information about MFCOM, be sure to check out Scripting MetaFrame Using MFCOM.
Technorati : Citrix, MFCOM, Management, Terminal Services, Windows PowerShell
Del.icio.us : Citrix, MFCOM, Management, Terminal Services, Windows PowerShell
Ice Rocket : Citrix, MFCOM, Management, Terminal Services, Windows PowerShell

Jason Conger Blog » Blog Archive » Using PowerShell to Manage Terminal Services Attributes Says:
February 20th, 2008 at 2:04 am
[…] PowerShell is quickly becoming the de facto standard scripting method for new Microsoft products. I’ve written in the past about using PowerShell in your environment, which focused mainly on using PowerShell in Citrix environments. PowerShell can also be used to bulk edit Terminal Services attributes as seen in a blog post by Dmitry Sotnikov. Dmitry demonstrates how to get and set Terminal Service attributes using some custom PowerShell cmdlets. Here is an excerpt from the blog post: […]
Jason Conger Blog » Blog Archive » Using PowerShell with Citrix Policies Says:
March 29th, 2008 at 11:03 pm
[…] Using PowerShell in Your Environment […]