<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx</link><description>&amp;lt;Edited 7/2/2006 to add tags and Categories&amp;gt; Ben Winzenz didn't like the fact that Windows PowerShell did not maintain history lists between sessions ( http://winzenz.blogspot.com/2006/06/cool-mshpowershell-tidbit.html ) . We hear you Ben. Back</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#653303</link><pubDate>Sat, 01 Jul 2006 10:40:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:653303</guid><dc:creator>barrkel</dc:creator><description>Will there ever be a way to run PowerShell via STDIN / STDOUT rather than in a Win32 console - such that it works in an Cygwin rxvt terminal? Currently, PowerShell appears to use Win32 Console commands to read input - which doesn't work when it's not attached to a console.&lt;br&gt;&lt;br&gt;I know that it would be far from ideal, but if it used STDIN/STDOUT then one could write a wrapper program that uses Readline and thus supplies nice history etc. support, and allow PowerShell to run in an rxvt terminal.&lt;br&gt;&lt;br&gt;My bash/rxvt already saves history between sessions, and it can save an arbitrary number of entries (more than 32KB - it works on lines rather than bytes). Rxvt also has nice paging support with Shift+PgUp/PgDn, which is one of the big reasons I don't use the Win32 console. Another big reason is that QuickEdit mode (i.e. mouse causing selection in Win32 console) causes the running application to freeze, while selecting in rxvt copies to the clipboard straight away, no need for pausing or anything. Also, rxvt has bold and underline, as well as colors.&lt;br&gt;&lt;br&gt;I've tried to use PowerShell, and it's the Win32 console window that's holding me back. I abandoned the Win32 console many years ago.&lt;br&gt;&lt;br&gt;Here's the stack trace of PowerShell frozen in an rxvt session:&lt;br&gt;&lt;br&gt;---8&amp;lt;---&lt;br&gt;ntkrnlpa.exe!KiSwapContext+0x2e&lt;br&gt;ntkrnlpa.exe!KiSwapThread+0x46&lt;br&gt;ntkrnlpa.exe!KeWaitForSingleObject+0x1c2&lt;br&gt;ntkrnlpa.exe!NtRequestWaitReplyPort+0x63d&lt;br&gt;ntkrnlpa.exe!KiFastCallEntry+0xf8&lt;br&gt;ntdll.dll!KiFastSystemCallRet&lt;br&gt;ntdll.dll!ZwRequestWaitReplyPort+0xc&lt;br&gt;ntdll.dll!CsrClientCallServer+0x8c&lt;br&gt;kernel32.dll!ReadConsoleInternal+0x1be&lt;br&gt;kernel32.dll!ReadConsoleW+0x42&lt;br&gt;mscorwks.dll!CallDescrWorker+0x33&lt;br&gt;mscorwks.dll!CallDescrWorkerWithHandler+0xa3&lt;br&gt;mscorwks.dll!MethodDesc::CallDescr+0x19c&lt;br&gt;mscorwks.dll!MethodDesc::CallTargetWorker+0x20&lt;br&gt;mscorwks.dll!MethodDescCallSite::Call+0x18&lt;br&gt;mscorwks.dll!InvokeImpl+0x43f&lt;br&gt;mscorwks.dll!RuntimeMethodHandle::InvokeMethodFast+0xbd&lt;br&gt;mscorlib.ni.dll+0x30f629&lt;br&gt;---&amp;gt;8---&lt;br&gt;&lt;br&gt;You can see in there the all-important call to ReadConsoleW rather than ReadFileW.</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#653723</link><pubDate>Sat, 01 Jul 2006 22:27:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:653723</guid><dc:creator>bwinzenz</dc:creator><description>Ahh - that rocks.&lt;br&gt;&lt;br&gt;Thanks for this info. &amp;nbsp;I very much appreciate it.</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#653732</link><pubDate>Sat, 01 Jul 2006 22:52:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:653732</guid><dc:creator>KeithH</dc:creator><description>It sure would be nice to be able to hook a &amp;quot;PSExiting&amp;quot; event in a profile script and then save history right before exit.</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#653733</link><pubDate>Sat, 01 Jul 2006 22:53:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:653733</guid><dc:creator>KeithH</dc:creator><description>BTW, I would change this:&lt;br&gt;&lt;br&gt;Get-History -Count 1KB &lt;br&gt;&lt;br&gt;to &lt;br&gt;&lt;br&gt;Get-History -Count $MaximumHistoryCount</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#653769</link><pubDate>Sat, 01 Jul 2006 23:58:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:653769</guid><dc:creator>PowerShellTeam</dc:creator><description>&amp;gt; It sure would be nice to be able to hook a &amp;quot;PSExiting&amp;quot; event in a &lt;br&gt;&amp;gt; profile script and then save history right before exit. &lt;br&gt;&lt;br&gt;This requires the EVENTING architecture that we'll be working on for V2&lt;br&gt;&lt;br&gt;RE: -COUNT $MaximumHistoryCount &lt;br&gt;Great catch!&lt;br&gt;&lt;br&gt;Jeffrey Snover &lt;br&gt;Windows PowerShell Architect</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#654103</link><pubDate>Sun, 02 Jul 2006 08:10:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:654103</guid><dc:creator>dontBotherMeWithSpam</dc:creator><description>For this kind of occasion, I have been thinking about asking this question:&lt;br&gt;&lt;br&gt;Is there a way to know that powershell &amp;nbsp;is exiting and run whatever the scripts needed to be run instead of using such custom function as &amp;quot;BYE&amp;quot; to persist certain PowerShell states?&lt;br&gt;&lt;br&gt;Since PowerShell reads profile when starting up, how about a profile file for when PowerShell is &amp;quot;exiting&amp;quot;?(if that functionality had been there, we could execute those commands for persisting history list across sessions.</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#654617</link><pubDate>Sun, 02 Jul 2006 22:04:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:654617</guid><dc:creator>PowerShellTeam</dc:creator><description>&amp;gt; Is there a way to know that powershell &amp;nbsp;is exiting and run whatever the scripts needed to be &lt;br&gt;&amp;gt; run instead of using such custom function as &amp;quot;BYE&amp;quot; to persist certain PowerShell states? &lt;br&gt;&lt;br&gt;This is a perfectly reasonable expectation. &amp;nbsp;We wanted to do this but didn't have the time for V1.0&lt;br&gt;&lt;br&gt;Jeffrey Snover&lt;br&gt;Windows PowerShell Architect</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#655262</link><pubDate>Mon, 03 Jul 2006 17:14:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:655262</guid><dc:creator>bwinzenz</dc:creator><description>Just wanted to leave a quick comment letting you know that the code you included didn't work for me. &amp;nbsp;I am using the Exchange Management Shell (Exchange 2007), and it was throwing errors on a few things.&lt;br&gt;&lt;br&gt;First, it didn't like the $MaximumHistoryCount = 1KB. &amp;nbsp;I changed it to $MaximumHistoryCount = 1000 and it was happy.&lt;br&gt;&lt;br&gt;Second, the code:&lt;br&gt;if (!(Test-Path ~\PowerShell -PathType Container))&lt;br&gt;{ &amp;nbsp; New-Item ~\PowerShell -ItemType Directory&lt;br&gt;}&lt;br&gt;&lt;br&gt;also resulted in an error. &amp;nbsp;Specifically, &amp;quot;A parameter cannot be found that matches parameter 'PathType'&amp;quot;&lt;br&gt;&lt;br&gt;I simply removed those lines, and everything seems to work fine now. &amp;nbsp;Here is the resulting code that I am using in the Exchange Management Shell.&lt;br&gt;&lt;br&gt;$MaximumHistoryCount = 1000&lt;br&gt;&lt;br&gt;function bye &lt;br&gt;{ &amp;nbsp; Get-History -Count $MaximumHistoryCount |Export-CSV ~\history.csv&lt;br&gt; &amp;nbsp; &amp;nbsp;exit&lt;br&gt;}&lt;br&gt;&lt;br&gt;if (Test-path ~\History.csv)&lt;br&gt;{ &amp;nbsp; Import-CSV ~\History.csv |Add-History&lt;br&gt;}&lt;br&gt;</description></item><item><title>re: Automating PowerShell</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#655610</link><pubDate>Tue, 04 Jul 2006 02:31:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:655610</guid><dc:creator>PowerShellTeam</dc:creator><description>Barrkel: &amp;nbsp;There are two ways to use PowerShell without the Win32 console -- either by hosting the engine yourself, or by using the -command parameter. &amp;nbsp;See if this helps your cause:&lt;br&gt;&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://www.leeholmes.com/blog/UsingMshexeInteractivelyFromWithinOtherPrograms.aspx"&gt;http://www.leeholmes.com/blog/UsingMshexeInteractivelyFromWithinOtherPrograms.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;Lee</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#655614</link><pubDate>Tue, 04 Jul 2006 02:36:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:655614</guid><dc:creator>PowerShellTeam</dc:creator><description>bwinzenz:&lt;br&gt;&lt;br&gt;Jeffrey is giving you a sneak preview of an upcoming build :) &amp;nbsp;The Exchange Management shell will soon have this same syntax, but for now you'll have to replace:&lt;br&gt;&lt;br&gt;1kb with 1k&lt;br&gt;&lt;br&gt;As for the -PathType option, you can determine the parameter by typing the following:&lt;br&gt;&lt;br&gt;(get-command test-path).Definition&lt;br&gt;&lt;br&gt;One of those should be close to &amp;quot;PathType&amp;quot; -- we went through a renaming phase a while back, which is why you see the difference.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#3552209</link><pubDate>Tue, 26 Jun 2007 23:37:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3552209</guid><dc:creator>zelial</dc:creator><description>&lt;p&gt;Hi and thanks for the code. But I have a problem with the imported history: it can't be traversed interactively (with the up and down arrows). is there a way to let the console know about these new commands in history?&lt;/p&gt;</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#4137627</link><pubDate>Tue, 31 Jul 2007 01:52:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4137627</guid><dc:creator>Andrew Tearle</dc:creator><description>&lt;p&gt;In the interests of finding an existing object - perhaps the title could be better expressed as &amp;quot;Preserving Command History ...&amp;quot;&lt;/p&gt;
&lt;p&gt;Regards from Aotearoa&lt;/p&gt;
&lt;p&gt;Andy&lt;/p&gt;</description></item><item><title>Re: A pop-history Cmdl</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#5212156</link><pubDate>Sun, 30 Sep 2007 20:19:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5212156</guid><dc:creator>Latest Newsgroup Posts</dc:creator><description>&lt;p&gt;See if this blog entry helps. Perserving Command History Across Sessions [link]&lt;/p&gt;
</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#7815025</link><pubDate>Wed, 20 Feb 2008 13:25:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7815025</guid><dc:creator>Alexi</dc:creator><description>&lt;p&gt;Yeah, I second the PSExiting hook request. Is there a general way to hook events in powershell? Some searching turned out dry.&lt;/p&gt;</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#7818689</link><pubDate>Wed, 20 Feb 2008 17:36:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7818689</guid><dc:creator>PowerShellTeam</dc:creator><description>&lt;p&gt;&amp;gt; Is there a general way to hook events in powershell? &lt;/p&gt;
&lt;p&gt;Not in V1. &amp;nbsp;We'll take that as a V2 feature request. &amp;nbsp;We checked in that code last night.&lt;/p&gt;
&lt;p&gt;Pretty responsive eh?&lt;/p&gt;
&lt;p&gt;Jeffrey Snover [MSFT]&lt;/p&gt;
&lt;p&gt;Windows Management Partner Architect&lt;/p&gt;
&lt;p&gt;Visit the Windows PowerShell Team blog at: &amp;nbsp; &amp;nbsp;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/PowerShell"&gt;http://blogs.msdn.com/PowerShell&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Visit the Windows PowerShell ScriptCenter at: &amp;nbsp;&lt;a rel="nofollow" target="_new" href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx"&gt;http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Commonality - The Command History in PowerShell</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#7927911</link><pubDate>Thu, 28 Feb 2008 06:12:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7927911</guid><dc:creator>Commonality - The Command History in PowerShell</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.winterdom.com/weblog/2008/02/28/TheCommandHistoryInPowerShell.aspx"&gt;http://www.winterdom.com/weblog/2008/02/28/TheCommandHistoryInPowerShell.aspx&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>random thoughts  &amp;raquo; MSH/Powershell Followup</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#8579605</link><pubDate>Sat, 07 Jun 2008 09:26:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8579605</guid><dc:creator>random thoughts  &amp;raquo; MSH/Powershell Followup</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://thought.mobiforumz.com/2006/07/02/mshpowershell-followup/"&gt;http://thought.mobiforumz.com/2006/07/02/mshpowershell-followup/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Random Thoughts  &amp;raquo; Blog Archive   &amp;raquo; MSH/Powershell Followup</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#8720882</link><pubDate>Fri, 11 Jul 2008 13:23:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8720882</guid><dc:creator>Random Thoughts  &amp;raquo; Blog Archive   &amp;raquo; MSH/Powershell Followup</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://winzenz.mobiforumz.com/2006/07/02/mshpowershell-followup/"&gt;http://winzenz.mobiforumz.com/2006/07/02/mshpowershell-followup/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Perserving Command History Across Sessions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#8972843</link><pubDate>Thu, 02 Oct 2008 07:40:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8972843</guid><dc:creator>Pat Richard</dc:creator><description>&lt;p&gt;Is there a way to import the data so that it's available when pressing F7?&lt;/p&gt;</description></item><item><title>And the event driven solution arrived</title><link>http://blogs.msdn.com/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx#9575024</link><pubDate>Wed, 29 Apr 2009 08:02:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9575024</guid><dc:creator>Neil Fairall</dc:creator><description>&lt;p&gt;See &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/powershell/archive/2008/06/11/powershell-eventing-quickstart.aspx"&gt;http://blogs.msdn.com/powershell/archive/2008/06/11/powershell-eventing-quickstart.aspx&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>