{"id":63,"date":"2015-01-05T23:15:32","date_gmt":"2015-01-05T23:15:32","guid":{"rendered":"http:\/\/robinplomp.com\/?p=63"},"modified":"2015-01-06T08:09:42","modified_gmt":"2015-01-06T08:09:42","slug":"create-powershell-profile-ready-xendesktop-management","status":"publish","type":"post","link":"https:\/\/robinplomp.com\/?p=63","title":{"rendered":"Create a PowerShell Profile ready for XenDesktop Management"},"content":{"rendered":"<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/PowerShell_Logo.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"99\" height=\"99\" title=\"PowerShell_Logo\" align=\"left\" style=\"border-width: 0px; margin-right: 0px; margin-left: 0px; display: inline;\" alt=\"PowerShell_Logo\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/PowerShell_Logo_thumb.jpg\" border=\"0\"><\/a> Today I want to show you how to create a PowerShell instance that is all ready for managing a Citrix XenDesktop 7.1 environment.<\/p>\n<p>We\u2019ve all been there you want to check something quickly in your environment. You start up PowerShell, enter a command and you are presented with an error message that the command you just entered is not recognized by PowerShell.<\/p>\n<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050621.34.56.png\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"131\" title=\"Screenshot 2014-05-06 21.34.56\" style=\"border-width: 0px; display: inline;\" alt=\"Screenshot 2014-05-06 21.34.56\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050621.34.56_thumb.png\" border=\"0\"><\/a><\/p>\n<p>We get this error message not because of a typo but because the Citrix Snap-ins are not loaded in this PowerShell session.<\/p>\n<p><!--more-->I want to be able to launch a PowerShell window and start with managing my Citrix XenDesktop Environment right away. To make this possible we have to create a PowerShell Profile.<\/p>\n<p><!--more--><\/p>\n<p>Before we can start with creating a PowerShell Profile we first have to make sure that there is not already a PowerShell Profile present. We can do this with the following one-liner:<\/p>\n<pre class=\"lang:ps decode:true \">Test-Path $profile<\/pre>\n<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050621.55.21.png\"><img loading=\"lazy\" decoding=\"async\" width=\"431\" height=\"81\" title=\"Screenshot 2014-05-06 21.55.21\" style=\"border-width: 0px; display: inline;\" alt=\"Screenshot 2014-05-06 21.55.21\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050621.55.21_thumb.png\" border=\"0\"><\/a><\/p>\n<p>$Profile is a build in variable in PowerShell for storing the path to the default PowerShell profile. As you can see the screenshot above in this environment we do not yet have a PowerShell profile.<\/p>\n<p>To create a new PowerShell profile we use the following PowerShell one-liner:<\/p>\n<pre class=\"lang:ps decode:true \">New-Item \u2013Path $Profile \u2013Type File \u2013Force<\/pre>\n<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.03.56.png\"><img loading=\"lazy\" decoding=\"async\" width=\"439\" height=\"140\" title=\"Screenshot 2014-05-06 22.03.56\" style=\"border-width: 0px; display: inline;\" alt=\"Screenshot 2014-05-06 22.03.56\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.03.56_thumb.png\" border=\"0\"><\/a><\/p>\n<p>As you can see we have now created an empty PowerShell profile. The next thing you want to do is altering the profile for your needs.<br \/>To edit the empty profile use the following PowerShell one-liner:<\/p>\n<pre class=\"lang:ps decode:true \">notepad $profile<\/pre>\n<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.16.11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"360\" height=\"83\" title=\"Screenshot 2014-05-06 22.16.11\" style=\"border-width: 0px; display: inline;\" alt=\"Screenshot 2014-05-06 22.16.11\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.16.11_thumb.png\" border=\"0\"><\/a><\/p>\n<p>I\u2019ve edited the profile file for it to include the loading of the Citrix Snap-ins. When I restart the PowerShell window I can immediately execute a Citrix PowerShell cmdlet.<\/p>\n<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/2014050622_23_12Screenshot2014050622.22.42.png\"><img loading=\"lazy\" decoding=\"async\" width=\"353\" height=\"226\" title=\"2014-05-06 22_23_12-Screenshot 2014-05-06 22.22.42\" style=\"border-width: 0px; display: inline;\" alt=\"2014-05-06 22_23_12-Screenshot 2014-05-06 22.22.42\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/2014050622_23_12Screenshot2014050622.22.42_thumb.png\" border=\"0\"><\/a><\/p>\n<p><strong>Bonus<br \/><\/strong>Here is a fun bonus to show what else you can do with a PowerShell Profile. Sometimes you need to run PowerShell with elevated rights. I always keep my PowerShell windows open, and I forget if PowerShell is started with elevated rights. So here is a little tip I use to see immediately that this is a PowerShell session with elevated rights.<\/p>\n<p>Open your PowerShell profile with notepad.<\/p>\n<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.38.25.png\"><img loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"117\" title=\"Screenshot 2014-05-06 22.38.25\" style=\"border-width: 0px; display: inline;\" alt=\"Screenshot 2014-05-06 22.38.25\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.38.25_thumb.png\" border=\"0\"><\/a><\/p>\n<p>When you launch PowerShell with elevated rights:<\/p>\n<p><a href=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.40.04.png\"><img loading=\"lazy\" decoding=\"async\" width=\"370\" height=\"88\" title=\"Screenshot 2014-05-06 22.40.04\" style=\"border-width: 0px; display: inline;\" alt=\"Screenshot 2014-05-06 22.40.04\" src=\"http:\/\/robinplomp.com\/wp-content\/uploads\/2015\/01\/Screenshot2014050622.40.04_thumb.png\" border=\"0\"><\/a><\/p>\n<p>This is it for now, may the code be with you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I want to show you how to create a PowerShell instance that is all ready for managing a Citrix XenDesktop 7.1 environment. We\u2019ve all been there you want to check something quickly in your environment. You start up PowerShell, enter a command and you are presented with an error message that the command you &hellip; <a href=\"https:\/\/robinplomp.com\/?p=63\" class=\"more-link\">Lees verder <span class=\"screen-reader-text\">Create a PowerShell Profile ready for XenDesktop Management<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,15],"tags":[10,11,12,13],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-powershell","category-xendesktop","tag-citrix","tag-powershell","tag-profile","tag-xendesktop-7-1"],"_links":{"self":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=63"}],"version-history":[{"count":2,"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions\/83"}],"wp:attachment":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}