{"id":3640,"date":"2016-03-09T21:16:04","date_gmt":"2016-03-09T21:16:04","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=3640"},"modified":"2016-03-09T21:16:04","modified_gmt":"2016-03-09T21:16:04","slug":"powershell-profile","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/powershell-profile\/","title":{"rendered":"Powershell $profile"},"content":{"rendered":"<p><strong>What&#8217;s the purpose of the $profile<\/strong><\/p>\n<p>The $profile (like a bash script configuration) allows us to configure the way our Powershell command shell looks, or sets the default location, we can add commands and aliases etc.<\/p>\n<p><strong>Where&#8217;s the $profile and does it exist?<\/strong><\/p>\n<p>Typing the following will result in Powershell telling us where the Microsoft.PowerShell_profile.ps1 file is expected to be<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n$profile\r\n<\/pre>\n<p>Just because $profile outputs a path, does not mean there&#8217;s a file&#8217;s there. It&#8217;s simply telling us where it goes to get the profile, we may still need to created one, instead we can use the following<\/p>\n<p>We can find out whether a $profile already exists using<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nTest-Path $profile\r\n<\/pre>\n<p><em>Test-Path determines whether all elements of a path exists, i.e. in this case, does the file exist<\/em><\/p>\n<p><strong>Creating the profile file<\/strong><\/p>\n<p>Typing<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nNew-Item -path $profile -itemType file -force\r\n<\/pre>\n<p>will create a new item (in this case a file) at the location (and name) supplied by the $profile variable. The force switch ensure the file is overwritten if it already exists.<\/p>\n<p>The ps1 file is just a text file, so from the command line you can run Notepad or powershell_ise (or ofcourse from the Windows GUI you can do the same) and edit the file, allow us to enter the commands that might want available from session to session.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What&#8217;s the purpose of the $profile The $profile (like a bash script configuration) allows us to configure the way our Powershell command shell looks, or sets the default location, we can add commands and aliases etc. Where&#8217;s the $profile and does it exist? Typing the following will result in Powershell telling us where the Microsoft.PowerShell_profile.ps1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[118],"tags":[],"class_list":["post-3640","post","type-post","status-publish","format-standard","hentry","category-powershell"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=3640"}],"version-history":[{"count":8,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3640\/revisions"}],"predecessor-version":[{"id":3666,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3640\/revisions\/3666"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=3640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=3640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=3640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}