<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results for 'app:weblogs' matching tag 'Profile'</title><link>http://powershell.com/cs/search/SearchResults.aspx?q=app:weblogs&amp;tag=Profile&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tag 'Profile'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>PowerShell Version Profiles</title><link>http://powershell.com/cs/blogs/lonelyadministrator/archive/2013/05/15/powershell-version-profiles.aspx</link><pubDate>Wed, 15 May 2013 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:23508</guid><dc:creator>Anonymous</dc:creator><description>One of the best things about PowerShell 3.0, for me anyway, is the ability to run PowerShell 2.0 side by side. I often need to test commands and scripts in both versions not only for my writing projects but also when helping people out. Like many of you I have a PowerShell profile script that [...]</description></item><item><title>PowerShell Version Profile Tips</title><link>http://powershell.com/cs/blogs/lonelyadministrator/archive/2012/09/12/powershell-version-profile-tips.aspx</link><pubDate>Wed, 12 Sep 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:19057</guid><dc:creator>Anonymous</dc:creator><description>
Now that PowerShell v3 is finally and officially with us, I&amp;#8217;m trusting that many of you are embracing it. I&amp;#8217;ve made the jump, although I have had to make some minor adjustments. If you are going to live entirely in &amp;#8230; &lt;a href="http://jdhitsolutions.com/blog/2012/09/powershell-version-profile-tips/"&gt;Continue reading &lt;span class="meta-nav"&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;</description></item><item><title>Fun with PSDrive Locations</title><link>http://powershell.com/cs/blogs/lonelyadministrator/archive/2012/07/10/fun-with-psdrive-locations.aspx</link><pubDate>Tue, 10 Jul 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:17612</guid><dc:creator>Anonymous</dc:creator><description>
A PowerShell PSDrive is a mapping between a PowerShell provider and a resource. The majority of our work is done in a file system PSDrive that corresponds to a file system drive. Let me show you a little trick that &amp;#8230; &lt;a href="http://jdhitsolutions.com/blog/2012/07/fun-with-psdrive-locations/"&gt;Continue reading &lt;span class="meta-nav"&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;</description></item><item><title>Use PowerShell Commands from One Session in Another Session</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/11/25/use-powershell-commands-from-one-session-in-another-session.aspx</link><pubDate>Fri, 25 Nov 2011 06:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:13376</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;span style="font-family:Lucida Sans Typewriter;font-size:small;"&gt;&lt;b&gt;Summary&lt;/b&gt;: Learn how to automatically save commands from one session, and then use them in a new Windows PowerShell session.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Microsoft Scripting Guy, Ed Wilson, is here. One of the fun things about getting to travel around and talk to people who are using Windows PowerShell on a daily basis to automate their systems is the quality of the questions I receive. One question that has come up several times in the last month that the Scripting Wife and I have been traveling is, &amp;ldquo;How can I save my history when I exit Windows PowerShell, and then have that history available to me when I open up Windows PowerShell again?&amp;rdquo;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;I gave this some thought&amp;hellip; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;I decided that it would be trivial to import automatically saved history when Windows PowerShell starts, and that the &lt;i&gt;issue &lt;/i&gt;would be saving the Windows PowerShell history when Windows PowerShell exits. One student who was in my class in Irvine, California suggested that I automatically save each command into a history file as I type the commands. In this way, when I exit the Windows PowerShell console, I will already have an up-to-date history file. While this technique is not impossible, it could have an unintended performance hit, and I decided against it. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Another idea I had was to use the Windows PowerShell transcript. It is easy to start the transcript each time Windows PowerShell starts by adding the &lt;b&gt;Start-Transcript&lt;/b&gt; command to the Windows PowerShell profile. I could then parse the Windows PowerShell transcript and pull out all of the commands. After I had all of the commands, it would be possible to add them to the history. But that would require creating a &lt;b&gt;HistoryInfo&lt;/b&gt; object. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;In the end, I decided to create two functions and add them to my profile. The first function imports a saved history.xml file into the current Windows PowerShell session. The second function exports the current history to a history.xml file, and then it exits Windows PowerShell. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;The trick is to call the function that exports the history.xml file prior to exiting Windows PowerShell instead of clicking the &amp;ldquo;X&amp;rdquo; on the Windows PowerShell console, or typing &lt;i&gt;exit &lt;/i&gt;to exit Windows PowerShell. As always, when I create a function, I also like to create an alias for that function. The two commands from my profile that create the aliases are shown here.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;New-Alias -Name eps -Value Exit-PsWithHistory -description &amp;quot;mred alias&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;New-Alias -Name ips -Value Import-PSHistory -Description &amp;quot;mred alias&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Instead of automatically importing the saved history, I manually type the alias for my import saved history function. The reason for this is that I do not always want to import my saved history; but, this is simply the way I work. I could easily modify my profile so that I do import my history automatically, and then I could simply clear the history if I did not want to use it. It will require a bit of testing before I make up my mind as to which action is most efficient. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Here is my function to export command history to a history.xml file and exit Windows PowerShell. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-size:small;"&gt;&lt;b&gt;&lt;span style="font-family:Segoe;"&gt;Function Exit-PsWithHistory&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;If(!(Test-Path $PSHistory)) &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp; {New-Item -path $PSHistory -itemtype directory}&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp; Get-History -count $MaximumHistoryCount | Export-Clixml -Path (Join-Path $PSHistory -child history.xml)&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;Exit&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;} #end function Exit-PsWithHistory&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;The &lt;b&gt;Exit-PsWithHistory&lt;/b&gt; function relies on the &lt;b&gt;$PSHistory&lt;/b&gt; variable. This is a variable that I define in my Windows PowerShell profile, and it points to the folder I use to store my history.xml file. Here is the command that creates the &lt;b&gt;$PSHistory&lt;/b&gt; variable. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;$PSHistory = Join-path -path (split-path $PROFILE) -ChildPath history&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;So, I use the &lt;b&gt;Test-Path&lt;/b&gt; cmdlet to see if there is a folder named &lt;i&gt;History &lt;/i&gt;in my Windows PowerShell profile folder. If it does not exist, I create it by using the &lt;b&gt;New-Item&lt;/b&gt; cmdlet. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;If(!(Test-Path $PSHistory)) &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp; {New-Item -path $PSHistory -itemtype directory}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;I then use the &lt;b&gt;Get-History&lt;/b&gt; cmdlet to get all of the items in my command history. By default, the &lt;b&gt;Get-History&lt;/b&gt; cmdlet returns only 32 items from the history. If I want to get all of the commands in my command history, I have to specify a value for the &lt;i&gt;Count &lt;/i&gt;parameter. The most logical thing to do is to use the &lt;b&gt;$MaximumHistoryCount&lt;/b&gt; variable to specify this number. In this way, if I increase the maximum history count from the default value of 64 to another number, my function will always export all of the commands. I use the &lt;b&gt;Export-CliXML&lt;/b&gt; cmdlet to export my command history into an .xml file, and I use &lt;b&gt;Join-Path&lt;/b&gt; to create the path to my file. This command is shown here. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Get-History -count $MaximumHistoryCount | Export-Clixml -Path (Join-Path $PSHistory -child history.xml)&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;The last thing I do is call the &lt;i&gt;exit &lt;/i&gt;command to exit Windows PowerShell. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;The function to import my saved history.xml file appears here. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Function Import-PsHistory&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;If(Test-Path $PSHistory)&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp; Import-Clixml -Path (Join-Path -path $PSHistory -child history.xml) |&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp; Add-history&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;} #end function import-psHistory&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Once again, I use the &lt;b&gt;Test-Path&lt;/b&gt; cmdlet to ensure that the history folder exists. If it does, I assume that a history.xml file exists. This is not a major problem, because the only reason the History folder would exist, would be if I had created it. If I did create it, it should have been when I was exporting a history.xml file. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;If(Test-Path $PSHistory)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;The next thing I do is import the xml file, and pipeline it to the Add-History cmdlet. Here is that portion of the function.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Import-Clixml -Path (Join-Path -path $PSHistory -child history.xml) |&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp; Add-history&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;I bump up my maximum history by assigning a new value to the variable. Rather than typing a big, long, complicated number, I simply use the &lt;i&gt;kb &lt;/i&gt;administrative constant to allow me to create 2048 history entries. This command is shown here. &lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;$MaximumHistoryCount = 2kb&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;You might wonder, &amp;quot;How large&amp;nbsp;can I create the &lt;b&gt;$maximumHistoryCount&lt;/b&gt; variable?&amp;quot; To determine the maximum allowed value, I use the &lt;b&gt;Get-Variable&lt;/b&gt; cmdlet. This command is shown here.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Get-Variable MaximumAliasCount | select -ExpandProperty attributes&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MinRange&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MaxRange TypeId&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --------&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -------- ------&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1024&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32768 System.Management.Automation.Validat...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;One thing to keep in mind, is when you use the &lt;b&gt;Get-Variable&lt;/b&gt; cmdlet, do not include the dollar sign prefix. If I do include the dollar sign prefix of the variable, I obtain a rather cryptic error that states Windows PowerShell cannot find a variable with the name of 2048. Because I recognize that number as the value I had increased the &lt;b&gt;$maximumhistorycount&lt;/b&gt; variable to, it makes sense. I then drop the dollar sign, and return the &lt;b&gt;psvariable&lt;/b&gt; object. I then send the variable to the &lt;b&gt;Format-List&lt;/b&gt; cmdlet, and I choose all of the properties. The result reveals that there is an object hiding in the &lt;b&gt;attributes&lt;/b&gt; variable. I then pipe the &lt;b&gt;psvariable&lt;/b&gt; object to the &lt;b&gt;Select-Object&lt;/b&gt; cmdlet, and I use the &lt;i&gt;ExpandProperty &lt;/i&gt;parameter to expand the object that is stored in the &lt;b&gt;attributes&lt;/b&gt; property. These commands are shown here.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;get-variable maximumhistorycount&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;get-variable maximumhistorycount | fl *&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;get-variable maximumhistorycount | select -ExpandProperty attributes&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;The commands and their associated output are shown here. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0250.hsg_2D00_11_2D00_25_2D00_11_2D00_1.png"&gt;&lt;img alt="Image of command output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0250.hsg_2D00_11_2D00_25_2D00_11_2D00_1.png" title="Image of command output" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;In the following image, I show my profile with the two new functions, the two aliases, and the two variable assignments.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0207.hsg_2D00_11_2D00_25_2D00_11_2D00_2.png"&gt;&lt;img alt="Image of script" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0207.hsg_2D00_11_2D00_25_2D00_11_2D00_2.png" title="Image of script" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;To exit Windows PowerShell, I use the &lt;b&gt;eps&lt;/b&gt;&lt;i&gt; &lt;/i&gt;alias (my alias for the &lt;b&gt;Export-PsWithHistory&lt;/b&gt; function. When I start Windows PowerShell, my profile runs, and it loads the functions, aliases, and variables into memory. I then type the &lt;b&gt;Import-PsHistory&lt;/b&gt; command (I can also use the &lt;b&gt;ips&lt;/b&gt;&lt;i&gt; &lt;/i&gt;alias). After I do that, I populate my history with all of my previous commands. I use the &lt;b&gt;h&lt;/b&gt;&lt;i&gt; &lt;/i&gt;(alias for &lt;b&gt;Get-History&lt;/b&gt;) command to see what commands I now have available to me in my command history. This sequence of commands is shown in the image that follows.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/1680.hsg_2D00_11_2D00_25_2D00_11_2D00_3.png"&gt;&lt;img alt="Image of command output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/1680.hsg_2D00_11_2D00_25_2D00_11_2D00_3.png" title="Image of command output" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;There is one downside to this technique: Imported commands (via &lt;b&gt;Add-History&lt;/b&gt;) do not populate the up and down arrows. But, dude (or dudette), with 2048 potential commands in the command history, that would be a ridiculous amount of Up and Down arrowing; that is why there are single letter aliases for &lt;b&gt;Get-History&lt;/b&gt; and for &lt;b&gt;Invoke-History&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Segoe;font-size:small;"&gt;Join me tomorrow for the Weekend Scripter when I will explore more coolness related to Windows PowerShell.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:small;"&gt;&lt;span style="font-family:Segoe;"&gt;I invite you to follow me on &lt;/span&gt;&lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;&lt;span style="color:#0000ff;font-family:Segoe;"&gt;Twitter&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:Segoe;"&gt; and &lt;/span&gt;&lt;a href="http://bit.ly/scriptingguysfacebook"&gt;&lt;span style="color:#0000ff;font-family:Segoe;"&gt;Facebook&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:Segoe;"&gt;. If you have any questions, send email to me at &lt;/span&gt;&lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;&lt;span style="color:#0000ff;font-family:Segoe;"&gt;scripter@microsoft.com&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:Segoe;"&gt;, or post your questions on the &lt;/span&gt;&lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;&lt;span style="color:#0000ff;font-family:Segoe;"&gt;Official Scripting Guys Forum&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:Segoe;"&gt;. See you tomorrow. Until then, peace.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:small;"&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466750" width="1" height="1" alt="" /&gt;</description></item><item><title>The Scripting Wife Uses a Profile to Configure PowerShell</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/09/12/the-scripting-wife-uses-a-profile-to-configure-powershell.aspx</link><pubDate>Mon, 12 Sep 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12283</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: The Scripting Wife learns how to use a profile to configure the Windows PowerShell console.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. One of the coolest events of the year occurs in just a few days. Yes, that&amp;rsquo;s right, it&amp;rsquo;s &lt;a href="http://www.bouchercon.info/"&gt;Bouchercon in St. Louis&lt;/a&gt;. Bouchercon is a mystery writer&amp;rsquo;s conference, and the attendee list is a who&amp;rsquo;s-who among the cloak-and-dagger writer crowd. Conferees to Bouchercon also have the privilege of selecting the &lt;a href="http://www.bouchercon.info/history.html"&gt;Anthony awards&lt;/a&gt; for the best mysteries.&lt;/p&gt;
&lt;p&gt;It was a dark and stormy night in Charlotte, a town that knows how to keep its secrets, when a sudden disturbance in the other room cut through my concentration on my latest Windows PowerShell script like a dagger slicing through heavy drapery. As I moved stealthily through the foyer, across the living room, and into the kitchen, my eyes rapidly picked up the source of the cacophony of frustration-laden words that tumbled flat on the tile floor like yesterdays&amp;rsquo; newspaper. I peeked around the corner.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0272.hsg_2D00_9_2D00_12_2D00_11_2D00_1.jpg"&gt;&lt;img style="border:0px;" title="Photo of Ed &amp;quot;Bouchercon&amp;quot; Wilson peeking around corner" alt="Photo of Ed &amp;quot;Bouchercon&amp;quot; Wilson peeking around corner" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0272.hsg_2D00_9_2D00_12_2D00_11_2D00_1.jpg" width="491" height="452" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;So, what&amp;rsquo;s ya beef, sweetheart?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The Scripting Wife turned her gaze at me from her computer monitor and at that moment, I felt it. I felt it deep in the core of my being like a seven-inch stiletto plunged deep into my inner core, a spark of electricity that said she was the one. I looked down, and she was poking me in my stomach.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I am not beefing. I have never beefed in my entire life. What is wrong with you anyway? What&amp;rsquo;s with the trench coat and the fedora?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;A man on the job has to be prepared for all conditions, all emergencies, all kinds of stormy weather.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But we are inside. Besides, your &lt;a href="http://en.wikipedia.org/wiki/Humphrey_Bogart"&gt;Bogart&lt;/a&gt; voice is barely believable.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Don&amp;rsquo;t let the patter fool you, kid. Maybe I am not as tough as I am cracked up to be. Maybe that kind of a reputation is good for business. Inside, I might be a teddy bear, but don&amp;rsquo;t count on it. Besides, you knew it was Bogey.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Only because you always do Bogey. If you can get serious for a minute, I have a problem. Why do I always have to keep loading the PowerShell Community Extension Project every day?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Because you use it every day? That&amp;rsquo;s just a guess, but then my guesses are usually pretty good.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Of course, I use it every day, and that is why I need to load it.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Whadda I tell ya?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;No. I mean, you never seem to load it, but I know you use the cmdlets. How is that possible?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh, I see what you mean. What you need to do is to create a profile. In your profile, you can load modules you find useful, and that you want to have immediately available,&amp;rdquo; I explained.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Okay. So how do I get a profile,&amp;rdquo; she asked.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Well the first thing to do, is to ensure that you do not already have a profile. Open your Windows PowerShell console, and use the &lt;b&gt;Test-Path&lt;/b&gt; cmdlet to see if you have a profile. Use the &lt;b&gt;$profile&lt;/b&gt; automatic variable to refer to your profile,&amp;rdquo; I instructed.&lt;/p&gt;
&lt;p&gt;The Scripting Wife thought for a second, and typed the following command into the dark blue Windows PowerShell console:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Test-Path $PROFILE&lt;/p&gt;
&lt;p&gt;As the Scripting Wife was typing, she took advantage of the Windows PowerShell tab expansion feature. Therefore, she did not have to type the complete command. What she actually typed was:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Test-p&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;$p&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;&lt;/p&gt;
&lt;p&gt;In this case, &lt;i&gt;&amp;lt;tab&amp;gt;&lt;/i&gt; represents the Tab key on the keyboard; &lt;i&gt;&amp;lt;space&amp;gt;&lt;/i&gt; represents the spacebar; &lt;i&gt;&amp;lt;enter&lt;/i&gt;&amp;gt; represents the Enter key on the keyboard.&lt;/p&gt;
&lt;p&gt;On the Scripting Wife&amp;rsquo;s computer, &lt;b&gt;Test-Path $profile&lt;/b&gt; returns &lt;b&gt;False&lt;/b&gt;, which means that she does not have a profile. If your command returns &lt;b&gt;True&lt;/b&gt;, you can open it in Notepad by using the following command:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Notepad $profile&lt;/p&gt;
&lt;p&gt;To back up your profile, you can use this command (replace &lt;i&gt;destination folder&lt;/i&gt; with a folder on your local computer):&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Copy-item $profile destination folder&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Okay, I am assuming that I do not have a profile, because the &lt;b&gt;Test-Path&lt;/b&gt; command came back and said &lt;b&gt;False&lt;/b&gt;. So back to my original question: how do I get a profile?&amp;rdquo; she asked.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;It is simple. You use the &lt;b&gt;New-Item&lt;/b&gt; cmdlet to tell it that you want to create an &lt;b&gt;itemtype&lt;/b&gt; of file, and give it the &lt;b&gt;$profile&lt;/b&gt; variable. Just to be on the safe side, go ahead and use the &lt;b&gt;force&lt;/b&gt; switch.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;You mean you are going to forgo your corny Star Wars &amp;lsquo;Use the force, Luke&amp;rsquo; imitation?&amp;rdquo; she asked with a slightly disappointed voice.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Yeah, you never seem to laugh at that one.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I never seem to laugh at any of them, but it never stopped you before,&amp;rdquo; she said.&lt;/p&gt;
&lt;p&gt;The Scripting Wife said &amp;ldquo;New-Item &lt;i&gt;$profile&lt;/i&gt; dash itemtype file dash force&amp;rdquo; to herself as she typed the following command:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;New-Item $PROFILE -ItemType file &amp;ndash;Force&lt;/p&gt;
&lt;p&gt;The keys she actually typed are shown here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;New-i&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;$pr&amp;lt;tab&amp;gt; &amp;lt;space&amp;gt;-i&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;file&amp;lt;space&amp;gt;-f&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;&lt;/p&gt;
&lt;p&gt;The reason the Scripting Wife used &lt;b&gt;$pr&amp;lt;tab&amp;gt;&lt;/b&gt; was so that she did not have to tab past the &lt;b&gt;$pid&lt;/b&gt; variable, which she had to do when she first used the &lt;b&gt;Test-Path&lt;/b&gt; cmdlet. The commands and associated output are shown in the following figure.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/6366.hsg_2D00_9_2D00_12_2D00_11_2D00_2.jpg"&gt;&lt;img style="border:0px;" title="Image of commands and associated output" alt="Image of commands and associated output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/6366.hsg_2D00_9_2D00_12_2D00_11_2D00_2.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Obviously, it did something, but how is that going to automatically load the PowerShell Community Extensions for me?&amp;rdquo; she asked.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Patience, grasshopper,&amp;rdquo; I said in my best Kung Fu voice.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I think I prefer your Bogey to your Kung Fu voice. After all, I would rather be a babe than a grasshopper.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;That reminds me of a Simon and Garfunkel song.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh, no!&amp;rdquo; she cried in mock horror. &amp;ldquo;Just get on with it.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Okay, now you have two choices: you can open your profile in Notepad, or you can open it in the Windows PowerShell ISE,&amp;rdquo; I explained.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Let&amp;rsquo;s use Notepad. It is faster,&amp;rdquo; she said.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;All right. Type &lt;b&gt;Notepad $profile&lt;/b&gt;,&amp;rdquo; I said.&lt;/p&gt;
&lt;p&gt;The Scripting Wife did not hesitate as she typed the following command:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Notepad $profile&lt;/p&gt;
&lt;p&gt;What she actually typed is shown here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Notepad&amp;lt;space&amp;gt;$pr&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;&lt;/p&gt;
&lt;p&gt;After she pressed Enter, a blank Notepad appeared, as shown in the following figure.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2402.hsg_2D00_9_2D00_12_2D00_11_2D00_3.jpg"&gt;&lt;img style="border:0px;" title="Image of blank Notepad" alt="Image of blank Notepad" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2402.hsg_2D00_9_2D00_12_2D00_11_2D00_3.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Nothing happened,&amp;rdquo; she complained.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Are you kidding? You opened Notepad, and not only that, look at the title bar. See how it points to the same location you saw earlier when you used the &lt;b&gt;New-Item&lt;/b&gt; cmdlet to create your blank profile?&amp;rdquo;I asked.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Okay,&amp;rdquo; she replied with a somewhat hesitant voice.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now, we will add the command to load the &lt;b&gt;PSCX&lt;/b&gt;. After the command is added to your profile, it will happen each time you start the Windows PowerShell console. You ready?&amp;rdquo; I asked.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;You bet. Let&amp;rsquo;s do it.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Okay, in your open Notepad, add the &lt;b&gt;Import-Module pscx&lt;/b&gt; command on the first line, and then save and close Notepad.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;She quickly typed the following command:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Import-Module pscx&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I wish that tab expansion worked inside Notepad,&amp;rdquo; she complained.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;What I do is type the command in the Windows PowerShell console first. Then when I know the command works, I highlight it and copy it, so I can paste it in Notepad. Now, close Windows PowerShell, and open it back up.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Ok. So how do I know that it worked?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Use the &lt;b&gt;Get-Command&lt;/b&gt; cmdlet, and look for commands from the &lt;b&gt;PSCX&lt;/b&gt; module,&amp;rdquo; I said.&lt;/p&gt;
&lt;p&gt;The Scripting Wife used the &lt;b&gt;GCM&lt;/b&gt; alias instead of typing &lt;b&gt;Get-Command&lt;/b&gt;. Here is the command she typed:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;gcm -Module pscx&lt;/p&gt;
&lt;p&gt;The actual keystrokes she used are shown here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;gcm&amp;lt;space&amp;gt;-m&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;&lt;/p&gt;
&lt;p&gt;The output from that command is shown in the following figure.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5543.hsg_2D00_9_2D00_12_2D00_11_2D00_4.jpg"&gt;&lt;img style="border:0px;" title="Image of output from command" alt="Image of output from command" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5543.hsg_2D00_9_2D00_12_2D00_11_2D00_4.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Wow, that is cool. Thanks,&amp;rdquo; she said.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;You&amp;rsquo;re welcome, sweetheart,&amp;rdquo; I replied in my Bogey voice.&lt;/p&gt;
&lt;p&gt;She sprung from her chair and left the keyboard as if it were a thing on fire. Her perfume reminded the now-empty room that a vibrant being had once occupied the premises. The room seemed smaller now that she was gone.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The Scripting Wife will return tomorrow when she struggles to configure the Windows PowerShell ISE. I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. You can also follow &lt;a href="http://twitter.com/#!/scriptingwife"&gt;The Scripting Wife on Twitter&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3451697" width="1" height="1" alt="" /&gt;</description></item><item><title>PowerShell Profile Files</title><link>http://powershell.com/cs/blogs/under-the-stairs/archive/2010/04/17/powershell-profile-files.aspx</link><pubDate>Sat, 17 Apr 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:5320</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;PowerShell defines some special script files, called Profiles, that you can use to customise and configure a PowerShell Session, whether you are using Powershell.exe, PoweShellISE.exe or a customised version (e.g. Exchange Management Console). The neat thing about the profile is that it runs, at start-up of every PowerShell host, in dot sourced mode. Thus functions and variables defined in the profile persist in your shell.&lt;/p&gt;  &lt;p&gt;For each PowerShell Host, you have up to four potential profiles:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;AllUsersAllHosts&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;AllUsersCurrentHost&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1 (PowerShellISE.exe), or&lt;/li&gt;      &lt;li&gt;C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 (PowerShell.exe)&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;CurrentUserAllHosts&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;C:\Users\&amp;lt;username&amp;gt;\Documents\WindowsPowerShell\profile.ps1&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;CurrentUserCurrentHost&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;C:\Users\tfl\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1 (PowerShellISE.,exe), or&lt;/li&gt;      &lt;li&gt;C:\Users\tfl\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 (PowerShell.exe).&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;For both the CurrentHost files – these will vary depending on which host the script is run. Above shows the profile files for both PowerShell and PowerShell ISE. The profile files (obviously one each of the four!) run in the order noted above. This means the admin could, for example define some functions in the AllUsersAllHosts that you can override in your CurrentUser profiles.&lt;/p&gt;  &lt;p&gt;As it turns out, there’s a very PowerShell one-liner you can run to return your host’s profile files (and can even tell you if the file exists!) This one-liner looks like this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Courier New"&gt;&lt;strong&gt;$profile | gm *Host* | % { $_.Name } | % { $p = @{}; $p.Name = $_ ;$p.Path = $profile.$_; $p.Exists= (Test-Path $profile.$_); New-Object PSObject -Property $p } | Format-Table –AutoSize&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;I’ve &lt;a href="http://pshscripts.blogspot.com/2010/04/get-profilefileps1.html"&gt;posted a similar script&lt;/a&gt; over on my &lt;a href="http://pshscripts.blogspot.com/"&gt;PowerShell Scripts blog&lt;/a&gt;. The script I’ve posted on the PowerShell Scripts blog contains a Format-List (to look a bit better on the blog. You might prefer the Format-Table in the one-liner above.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dd10a934-aa0b-4553-888c-06539719f1c6" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/PowerShell" rel="tag"&gt;PowerShell&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Profile" rel="tag"&gt;Profile&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/5384857-2161588788147052125?l=tfl09.blogspot.com" alt="" /&gt;&lt;/div&gt;</description></item><item><title>Get-ProfileFile.ps1</title><link>http://powershell.com/cs/blogs/powershell-scripts/archive/2010/04/17/get-profilefile-ps1.aspx</link><pubDate>Sat, 17 Apr 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:5319</guid><dc:creator>Anonymous</dc:creator><description>  &lt;div id="hlDiv" class="dp-highlighter"&gt;   &lt;div class="bar"&gt;&lt;/div&gt;    &lt;ol class="dp-rb"&gt;     &lt;li class="alt"&gt;&lt;span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span class="comment"&gt;#&lt;/span&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;.SYNOPSIS&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; This script gets the details of the PowerShell profile files&lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; related &lt;/span&gt;&lt;span&gt;to a given host.&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;.DESCRIPTION&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; This script gets the 4 script file names from the &lt;span class="variable"&gt;$profile&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&lt;span class="variable"&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span&gt; variable and &lt;/span&gt;&lt;/span&gt;&lt;span&gt;creates a custom object containing the name and &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; path or each profile, and&lt;/span&gt;&lt;span&gt; whether that profile actually exists.&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;.NOTES&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; File Name&amp;#160; : Get-ProfileFile.ps1&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Author&amp;#160;&amp;#160;&amp;#160;&amp;#160; : Thomas Lee - tfl&lt;span class="variable"&gt;@psp&lt;/span&gt;&lt;span&gt;.co.uk&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Requires&amp;#160;&amp;#160; : PowerShell Version 2.0&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;.LINK&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; This script posted to:&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a title="http://pshscripts.blogspot.com/2010/04/get-profilefileps1.html" href="http://pshscripts.blogspot.com/2010/04/get-profilefileps1.html"&gt;http://pshscripts.blogspot.com/2010/04/get-profilefileps1.html&lt;/a&gt;&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;.EXAMPLE&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; [PS] C:\foo:&amp;gt; .\Get-ProfileFile.ps1&amp;#39;&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Name&amp;#160;&amp;#160; : AllUsersAllHosts&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Path&amp;#160;&amp;#160; : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Exists : True&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Name&amp;#160;&amp;#160; : AllUsersCurrentHosts&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Path&amp;#160;&amp;#160; : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Exists : False&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Name&amp;#160;&amp;#160; : CurrentUserAllHosts&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Path&amp;#160;&amp;#160; : C:\Users\tfl\Documents\WindowsPowerShell\profile.ps1&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Exists : True&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Name&amp;#160;&amp;#160; : CurrentUserCurrentHost&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Path&amp;#160;&amp;#160; : C:\Users\tfl\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; Exists : True&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&lt;span class="comment"&gt;#&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&lt;span class="comment"&gt;## &lt;/span&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&lt;span class="comment"&gt;# Start of Script&lt;/span&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&lt;span class="comment"&gt;##&lt;/span&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&lt;span class="variable"&gt;$profile&lt;/span&gt;&lt;span&gt; | gm *Host* | % { &lt;/span&gt;&lt;span class="variable"&gt;$_&lt;/span&gt;&lt;span&gt;.Name } | % {&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&lt;span class="variable"&gt;$rv&lt;/span&gt;&lt;span&gt; = @{}; &lt;/span&gt;&lt;span class="variable"&gt;$rv&lt;/span&gt;&lt;span&gt;.Name = &lt;/span&gt;&lt;span class="variable"&gt;$_&lt;/span&gt;&lt;span&gt; ;&lt;/span&gt;&lt;span class="variable"&gt;$rv&lt;/span&gt;&lt;span&gt;.Path = &lt;/span&gt;&lt;span class="variable"&gt;$profile&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span class="variable"&gt;$_&lt;/span&gt;&lt;span&gt;;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&lt;span class="variable"&gt;$rv&lt;/span&gt;&lt;span&gt;.Exists= (&lt;/span&gt;&lt;span class="builtin"&gt;Test-Path&lt;/span&gt;&lt;span&gt;&amp;#160;&lt;/span&gt;&lt;span class="variable"&gt;$profile&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span class="variable"&gt;$_&lt;/span&gt;&lt;span&gt;);&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&lt;span class="builtin"&gt;New-Object&lt;/span&gt;&lt;span&gt; PSObject -Property &lt;/span&gt;&lt;span class="variable"&gt;$rv&lt;/span&gt;&lt;span&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;} | &lt;span class="builtin"&gt;Format-List&lt;/span&gt;&lt;span&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;      &lt;li class="alt"&gt;&lt;span&gt;&amp;#160;&lt;/span&gt;&lt;/li&gt;      &lt;li class="class"&gt;&lt;span&gt;&lt;span class="comment"&gt;# End of script&lt;/span&gt;&lt;span&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;   &lt;/ol&gt; &lt;/div&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:558ac062-e1f9-4ae7-8e35-f72c65f39925" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/PowerShell" rel="tag"&gt;PowerShell&lt;/a&gt;,&lt;a href="http://technorati.com/tags/PowerShell+Script" rel="tag"&gt;PowerShell Script&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Profile" rel="tag"&gt;Profile&lt;/a&gt;,&lt;a href="http://technorati.com/tags/PowerShell+Profile" rel="tag"&gt;PowerShell Profile&lt;/a&gt;,&lt;a href="http://technorati.com/tags/PowerShell+Profile+File" rel="tag"&gt;PowerShell Profile File&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/546036873798832453-5668549648598156300?l=pshscripts.blogspot.com" alt="" /&gt;&lt;/div&gt;</description></item></channel></rss>