Tired of having to load the XD snap-in’s and new XD administration module everytime you launch a windows PoSH window outside of Studio? Well then join the club…

A PoSH profile is essentially a script file (.ps1) that can be used to customize a windows PoSH environment. The file is loaded each time a new instance of PoSH starts and can be used to load cmdlets, functions and even execute other .ps1 scripts straight off the bat.

In this short blog entry i’ll outline the steps needed to personalize your PoSH env so that it is fully loaded at start-up and ready to support all your XD needs.

Step 1: Check to see if you have an existing PoSH profile. To do this just open a PoSH window and type the following:

Test-Path $PROFILE

If the return value is true then wheather you knew it or not you have a PoSH profile ready to customize and you can jump to step 3. If the return value is false then you do not have a PoSH profile and must create one (Continue to step 2)

Note: By default, the profile file does not exist, even though PowerShell returns a path and filename when you query the $profile variable, the file must be created using the New-Item cmdlet or manually through notepad.

Step 2: Create a new PoSH profile. To do this just type the following and hit return:

New-Item -type file -force $PROFILE

Click on screenshot to view full image:

Note: -force This parameter tells New-Item cmdlet to create the full path and file no matter what and is needed if you receive an error like the one below where the WindowsPowerShell directory itself did not exist:

Click on screenshot to view full image:

Step 3: Configure your new PoSH profile. To do this just type notepad $profile and hit return:

Once the new PoSH profile opens up in notepad you can customize it as you see fit and save the changes. In the example below I have added two lines:

1.asnp citrix* (Load all XD snap-in’s)

2.Import-Module -name citrix.xendesktop.admin (Load the new XD administration module)

Note: make sure to save the changes when closing notepad so that changes to the PoSH profile will persist.

Click on screenshot to view full image:

Once you have carried out the steps above, each time you close and re-oepn PoSH, all XD cmdlets will be available automatically.  Why not go ahead and give it a shot…

Final Notes:

To Remove the PowerShell Profile just run Remove-Item $PROFILE

To edit the eixtsing profile just type notepad $profile again and save any further changes

Best Regards
Mick Glover (aka XD Tipster)
Senior Readiness Specialist,
Worldwide Support Readiness [EMEA]
Citrix Systems, Inc