<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://www.skepticats.com/LnBlog/themes/default/styles/rss.css" ?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<link>http://linlog.skepticats.com/feeds/PowerShell_news.xml</link>
<title>LinLog</title>
<description>Linux, Programming, and Computing in General</description>
<generator>LnBlog 1.0.0</generator>
<item>
<title>Putty alias</title>
<link>http://linlog.skepticats.com/entries/2010/08/Putty_alias.php</link>
<description>
&lt;p&gt;Here's a quick code post from my Powershell profile.  I keep copying this around every time I set up a new system, so maybe it will be useful to others.  And to me, since I can copy it off the web in the future rather than having to dig it up or recreate it.&lt;/p&gt;&lt;p&gt;Being an old-school UNIX guy, I get used to just typing &lt;code&gt;ssh hostname&lt;/code&gt; to access my servers.  So the Putty syntax of loading a profile annoys me.  To that end, I wrote a few little functions to add to my Powershell $profile to address this.  They just let me load a session by typing the familiar commands and don't require me to change syntax when using a profile versus connecting directly to a hostname.&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;br /&gt;function _puttyHasProfile {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$profile_name = $args[0].ToLower()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$profiles = Get-ChildItem HKCU:\Software\SimonTatham\PuTTY\Sessions\&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach ($p in $profiles) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$lowerName = [System.IO.Path]::GetFileName($p.Name).ToLower()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Need the UrlEncode to account for profile names with spaces.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($lowerName -eq [System.Web.HttpUtility]::UrlEncode($profile_name)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 0&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;function ssh {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$profile_name = $args[0]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (_puttyHasProfile($profile_name)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;putty -load $profile_name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;putty $args&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;function sftp {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$profile_name = $args[0]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (_puttyHasProfile($profile_name)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;psftp -load $profile_name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;psftp $args&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;
</description>
<author>pageer@skepticats.com (Peter Geer)</author>
<comments>http://linlog.skepticats.com/entries/2010/08/31_0931/comments/</comments>
<guid>http://linlog.skepticats.com/entries/2010/08/31_0931/</guid>
</item>
<item>
<title>PowerShell highlighting in Vim  </title>
<link>http://linlog.skepticats.com/entries/2009/01/PowerShell_highlighting_in_Vim.php</link>
<description>
&lt;p&gt;Well, I feel stupid.  I just finally got syntax highlighting for PowerShell to work in Vim.  I did a little Googling and found my solution in the PDF document linked form &lt;a href=&quot;http://port25.technet.com/archive/2008/05/29/technical-analysis-vim-powershell-and-signed-code.aspx&quot;&gt;this article&lt;/a&gt;.  Why you need an 8 page PDF to explain this is a completely different issue.&lt;/p&gt;&lt;p&gt;Turns out I was just missing some lines in my filetype.vim file.  I already had the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1327&quot;&gt;syntax&lt;/a&gt;, &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1815&quot;&gt;indent&lt;/a&gt;, and &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1816&quot;&gt;file type&lt;/a&gt; plugins, I just didn't think to add the code to activate them (for some reason I thought that stuff was loaded dynamically).  However, page 6 of that PDF gave the answer:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;quot; Powershell &lt;br /&gt;au BufNewFile,BufRead *.ps1,*.psc1    setf ps1 &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;I just added those lines to my filetype.vim, below the corresponding entries for Povray files, and voilà!  Syntax highlighting now works.&lt;/p&gt;
</description>
<author>pageer@skepticats.com (Peter Geer)</author>
<slash:comments>2</slash:comments>
<comments>http://linlog.skepticats.com/entries/2009/01/22_1014/comments/</comments>
<wfw:commentRss>http://linlog.skepticats.com/entries/2009/01/22_1014/comments/comments.xml</wfw:commentRss>
<guid>http://linlog.skepticats.com/entries/2009/01/22_1014/</guid>
</item>
</channel>
</rss>