<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Nivot Ink</title>
  <link rel="alternate" type="text/html" href="http://www.nivot.org/" />
  <link rel="self" href="http://www.nivot.org/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2008-07-01T15:43:07.99761-07:00</updated>
  <author>
    <name>Oisin Grehan</name>
  </author>
  <subtitle>powershell, .net, asp.net, enterprise computing and babble from Microsoft MVP Oisin Grehan.</subtitle>
  <id>http://www.nivot.org/</id>
  <generator uri="http://dasblog.info/" version="2.1.8086.808">DasBlog</generator>
  <entry>
    <title>PSParser Tricks #1 &amp;ndash; Resolve all Aliases to definitions in a script</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/07/01/PSParserTricks1NdashResolveAllAliasesToDefinitionsInAScript.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,cb3d0ce6-5acb-4257-9939-121ced333507.aspx</id>
    <published>2008-07-01T15:43:07.99761-07:00</published>
    <updated>2008-07-01T15:43:07.99761-07:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.nivot.org/CategoryView,category,NET.aspx" />
    <category term="Monad" label="Monad" scheme="http://www.nivot.org/CategoryView,category,Monad.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://www.nivot.org/CategoryView,category,PowerShell.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
Why do such a thing? Well, if you’ve created your own aliases for commands and you
try to give someone your ps1 script file, it will not run because they have not got
the same aliases defined as you. Also, scripts that use fully-resolved names like
“Get-ChildItem” are more readable for a newcomer to PowerShell than one that is using
the unix-like “ls" alias for example. "Get-ChildItem" leads quite directly to the
MSDN documentation, but "ls" might lead you anywhere. Before you publish a script
online somewhere for the world to use, it’s important that you try to remove any aliases
and replace them with the native command names.
</p>
        <p>
Doing this kind of thing has been talked about before but it was always a very difficult
thing to do with PowerShell v1.0, what with the lack of <a href="http://en.wikipedia.org/wiki/Backus-Naur_form" target="_blank">BNF</a> documentation
describing the grammar etc. Thankfully, it's a lot easier to do with PowerShell v2.0
(currently at release CTP2) because the team has exposed the <a href="http://en.wikipedia.org/wiki/Lexical_analysis" target="_blank">Tokenizer</a> for
use in scripts. There's been suprisingly little use of it so far, so I figured I'd
start the ball rolling with a series of articles based around it. So, let's look at
an example script that uses aliases and put it through the meat grinder:
</p>
        <p>
          <a href="http://www.nivot.org/content/binary/WindowsLiveWriter/PSParserTricks1ResolveallAliasestoComman_F64B/image_2.png">
            <img title="image" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="418" alt="image" src="http://www.nivot.org/content/binary/WindowsLiveWriter/PSParserTricks1ResolveallAliasestoComman_F64B/image_thumb.png" width="640" border="0" />
          </a>
        </p>
        <p>
As you can see, it spits out the expanded script to the output stream. The informational
messages are written to the host, so they won't interfere if you redirect the output
to a file like: .\resolve-aliases.ps1 in.ps1 &gt; out.ps1
</p>
        <p>
          <strong>Here's the Resolve-Aliases.ps1 script itself:</strong>
        </p>
        <!-- Stylesheet link -->
        <link href="http://www.thecomplex.plus.com/styles/SyntaxHighlighter.css" type="text/css" rel="stylesheet" />
        <!-- Code -->
        <div class="dp-highlighter" id="hlDiv">
          <div class="bar">
          </div>
          <ol class="dp-rb">
            <li class="alt">
              <span>
                <span class="comment">#requires -version 2 </span>
                <span>  </span>
              </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="keyword">param</span>
              <span>(</span>
              <span class="variable">$filename</span>
              <span> =
$(throw </span>
              <span class="string">"need filename!"</span>
              <span>))   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$lines</span>
              <span> = </span>
              <span class="variable">$null</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$path</span>
              <span> = </span>
              <span class="builtin">Resolve-Path</span>
              <span> </span>
              <span class="variable">$filename</span>
              <span> -ErrorAction
0   </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="keyword">if</span>
              <span> (</span>
              <span class="variable">$path</span>
              <span>)
{   </span>
            </li>
            <li class="">
              <span>    </span>
              <span class="variable">$lines</span>
              <span> = </span>
              <span class="builtin">Get-Content</span>
              <span> </span>
              <span class="variable">$path</span>
              <span>.path   </span>
            </li>
            <li class="alt">
              <span>} </span>
              <span class="keyword">else</span>
              <span> {   </span>
            </li>
            <li class="">
              <span>    </span>
              <span class="builtin">Write-Warning</span>
              <span> </span>
              <span class="string">"Could
not find $filename"</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>    exit   </span>
            </li>
            <li class="">
              <span>}   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="comment"># Initialize </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$parser</span>
              <span> = [system.management.automation.psparser]   </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$errors</span>
              <span> = new-object system.management.automation.psparseerror[]
0   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>do {   </span>
            </li>
            <li class="alt">
              <span>    </span>
              <span class="variable">$tokens</span>
              <span> = </span>
              <span class="variable">$parser</span>
              <span>:</span>
              <span class="symbol">:tokenize</span>
              <span>(</span>
              <span class="variable">$lines</span>
              <span>,
[ref]</span>
              <span class="variable">$errors</span>
              <span>)      </span>
            </li>
            <li class="">
              <span>    </span>
              <span class="variable">$retokenize</span>
              <span> = </span>
              <span class="variable">$false</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>       </span>
            </li>
            <li class="">
              <span>    </span>
              <span class="keyword">if</span>
              <span> (</span>
              <span class="variable">$errors</span>
              <span>.count
-gt 0) {   </span>
            </li>
            <li class="alt">
              <span>        </span>
              <span class="builtin">Write-Warning</span>
              <span> </span>
              <span class="string">"$($errors.count)
error(s) found in script."</span>
              <span>  </span>
            </li>
            <li class="">
              <span>        </span>
              <span class="variable">$errors</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>        exit   </span>
            </li>
            <li class="">
              <span>    }   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>    </span>
              <span class="comment"># look through tokens for commands </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>    </span>
              <span class="variable">$tokens</span>
              <span> | % {   </span>
            </li>
            <li class="">
              <span>        </span>
              <span class="keyword">if</span>
              <span> (</span>
              <span class="variable">$_</span>
              <span>.Type
-eq </span>
              <span class="string">"Command"</span>
              <span>) {   </span>
            </li>
            <li class="alt">
              <span>            </span>
              <span class="variable">$name</span>
              <span> = </span>
              <span class="variable">$_</span>
              <span>.Content   </span>
            </li>
            <li class="">
              <span>               </span>
            </li>
            <li class="alt">
              <span>            </span>
              <span class="comment">#
is it an alias? </span>
              <span>  </span>
            </li>
            <li class="">
              <span>            </span>
              <span class="comment">#
we use -literal here so '?' isn't treated as wildcard </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>            </span>
              <span class="keyword">if</span>
              <span> ((!(</span>
              <span class="variable">$name</span>
              <span> -eq </span>
              <span class="string">"."</span>
              <span>))
-and (</span>
              <span class="builtin">Test-Path</span>
              <span> -LiteralPath alias:</span>
              <span class="variable">$name</span>
              <span>))
{   </span>
            </li>
            <li class="">
              <span>                   </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="comment">#
gcm may return more than one match, so specify "alias" </span>
              <span>  </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="comment">#
filtering against name kludges the '?' alias/wildcard  </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="variable">$command</span>
              <span> =
gcm -CommandType alias </span>
              <span class="variable">$name</span>
              <span> | ? { </span>
              <span class="variable">$_</span>
              <span>.name
-eq </span>
              <span class="variable">$name</span>
              <span> }   </span>
            </li>
            <li class="">
              <span>                               </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="comment">#
resolve alias which may lead to another alias </span>
              <span>  </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="comment">#
so loop until we reach a non-alias </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>               
do {   </span>
            </li>
            <li class="">
              <span>                    </span>
              <span class="variable">$command</span>
              <span> = </span>
              <span class="builtin">Get-Command</span>
              <span> </span>
              <span class="variable">$command</span>
              <span>.definition   </span>
            </li>
            <li class="alt">
              <span>               
} </span>
              <span class="keyword">while</span>
              <span> (</span>
              <span class="variable">$command</span>
              <span>.CommandType
-eq </span>
              <span class="string">"Alias"</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>                   </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="builtin">Write-Host</span>
              <span> -NoNewline </span>
              <span class="string">"Resolved
"</span>
              <span>  </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="builtin">Write-Host</span>
              <span> -NoNewline
-ForegroundColor yellow </span>
              <span class="variable">$name</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>               
write-host -nonewline </span>
              <span class="string">" to "</span>
              <span>    </span>
            </li>
            <li class="">
              <span>               
write-host -ForegroundColor green </span>
              <span class="variable">$command</span>
              <span>.name            </span>
            </li>
            <li class="alt">
              <span>                   </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="comment">#
Use a stringbuilder to replace the alias in the line </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="comment">#
pointed to in the Token object. StringBuilder has a much </span>
              <span>  </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="comment">#
more precise Replace method than String. This allows us to </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="comment">#
replace the token with 100% confidence. </span>
              <span>  </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="variable">$sb</span>
              <span> = </span>
              <span class="builtin">New-Object</span>
              <span> text.stringbuilder </span>
              <span class="variable">$lines</span>
              <span>[</span>
              <span class="variable">$_</span>
              <span>.startline
- 1]   </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="variable">$sb</span>
              <span> = </span>
              <span class="variable">$sb</span>
              <span>.replace(</span>
              <span class="variable">$name</span>
              <span>, </span>
              <span class="variable">$command</span>
              <span>.Name, </span>
              <span class="variable">$_</span>
              <span>.startcolumn
- 1, </span>
              <span class="variable">$_</span>
              <span>.length)   </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="variable">$lines</span>
              <span>[</span>
              <span class="variable">$_</span>
              <span>.startline
- 1] = </span>
              <span class="variable">$sb</span>
              <span>.tostring()   </span>
            </li>
            <li class="alt">
              <span>                   </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="comment">#
now that we've replaced a token, the script needs to be reparsed </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>                </span>
              <span class="comment">#
as offsets have changed on this line.  </span>
              <span>  </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="variable">$retokenize</span>
              <span> = </span>
              <span class="variable">$true</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>                   </span>
            </li>
            <li class="">
              <span>                </span>
              <span class="comment">#
break out of pipeline, (not 'do' loop) </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>               
continue;   </span>
            </li>
            <li class="">
              <span>            }   </span>
            </li>
            <li class="alt">
              <span>        }   </span>
            </li>
            <li class="">
              <span>    }   </span>
            </li>
            <li class="alt">
              <span>} </span>
              <span class="keyword">while</span>
              <span> (</span>
              <span class="variable">$retokenize</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="builtin">Write-Host</span>
              <span> </span>
              <span class="string">""</span>
              <span> </span>
              <span class="comment">#
blank line </span>
              <span>  </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="comment"># output our modified script </span>
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$lines</span>
              <span>  </span>
            </li>
          </ol>
        </div>
        <p>
        </p>
        <p>
        </p>
        <p>
Of course, this requires PowerShell v2.0 CTP2. Next in the series, I'll give you a
script to check your ps1 scripts for backwards compatibility against PowerShell 1.0.
That should be handy for those naughty admins out there who despite all the warnings
have installed v2 in production. ;-)
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=cb3d0ce6-5acb-4257-9939-121ced333507" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Workaround to force PowerShell redirection operator to use ASCII encoding</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/06/27/WorkaroundToForcePowerShellRedirectionOperatorToUseASCIIEncoding.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,59d45a0b-5cd5-4996-8015-ed24918608c4.aspx</id>
    <published>2008-06-27T09:03:07.7993817-07:00</published>
    <updated>2008-06-27T09:31:40.6946691-07:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.nivot.org/CategoryView,category,NET.aspx" />
    <category term="Monad" label="Monad" scheme="http://www.nivot.org/CategoryView,category,Monad.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://www.nivot.org/CategoryView,category,PowerShell.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Someone on a private mailing list I'm on lamented the problem with powershell's '&gt;'
redirection operator defaulting inflexibly to use unicode for encoding the output
file. This is not very compatible for NT's ancient console subsystem which works best
with ASCII data. Fortunately, there's an easy workaround to fix this:
</p>
        <p>
Due to the magic of command discovery and the fact that &gt; really does use out-file,
you can "fix" this by placing the following in your $profile:<br /><br /><font face="courier ">function out-file($FilePath, $Encoding, [switch]$Append) {<br />
$input | microsoft.powershell.utility\out-file $filepath -encoding ascii `<br />
     -append:$append<br />
} </font></p>
        <p>
          <br />
From now on, &gt; will be forced to use ASCII encoding. This works because functions
have higher precedence than built-in commands in powershell's command discovery search. 
</p>
        <p>
          <strong>UPDATE: </strong>Rather annoyingly, I'm informed that this particular workaround
doesn't work on v1.0 of PowerShell. I tested the above on v2.0CTP2 only. Doh.
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=59d45a0b-5cd5-4996-8015-ed24918608c4" />
      </div>
    </content>
  </entry>
  <entry>
    <title>VMWare and Windows Server 2008 &amp;ndash; Choppy Display Performance</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/06/25/VMWareAndWindowsServer2008NdashChoppyDisplayPerformance.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,b9a039b8-48bd-4dac-af9b-e78f543447e8.aspx</id>
    <published>2008-06-25T11:18:30.2145348-07:00</published>
    <updated>2008-06-25T16:15:45.8347611-07:00</updated>
    <category term="VMWare" label="VMWare" scheme="http://www.nivot.org/CategoryView,category,VMWare.aspx" />
    <category term="Windows Server 2008" label="Windows Server 2008" scheme="http://www.nivot.org/CategoryView,category,WindowsServer2008.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
Just another quick-fix post for any readers’ benefit. I have been using MOSS on Windows
2008 Server on VMWare for a while now and the display has always been sluggish and
choppy even though VMWare tools is up-to-date and installed. I decided to take a quick
peek at the display properties to see if perhaps hardware acceleration is off or something
like that and I noticed that the display driver was “Standard VGA Display.” I thought
to myself, “Shouldn’t that be a VMWare display driver?” so I clicked properties and
drilled down to the “Update Driver…” dialog. Clickety-click and hey presto, it finds
a newer driver, namely “VMWare SVGA II” and installs it. Display is now much better.
On other guest OS’s like Win 2003 etc, VMWare tools installation updated the driver
for you, but this time it didn’t. Not sure why. 
</p>
        <p>
          <strike>One remaining problem I have is that the mouse is dodgy and sometimes the
host mouse pointer gets de-synced with the guest’s. Anyone got that problem?</strike> 
Fixed by starting device manager and going through nearly the same drill as the display
driver. I manually chose “VMWare Pointing Device” and rebooted, replacing the default
ps/2 mouse driver.
</p>
        <p>
          <a href="http://www.nivot.org/content/binary/WindowsLiveWriter/VMWareandWindowsServer2008ChoppyDisplayP_C938/image_2.png">
            <img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 8px 0px 0px 8px; border-right-width: 0px" height="196" alt="image" src="http://www.nivot.org/content/binary/WindowsLiveWriter/VMWareandWindowsServer2008ChoppyDisplayP_C938/image_thumb.png" width="244" align="right" border="0" />
          </a>
        </p>
        <p>
          <strong>Update: </strong>
        </p>
        <p>
After I rebooted, it was still a little sluggish. Then I remembered that by default,
hardware acceleration is only at one notch up. So, push it up to full!
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=b9a039b8-48bd-4dac-af9b-e78f543447e8" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Dev-SysAdmin Meme</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/06/19/DevSysAdminMeme.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,ddb76bd8-36ca-44e4-8606-45768c8bae93.aspx</id>
    <published>2008-06-18T17:31:00-07:00</published>
    <updated>2008-06-19T10:34:17.7465828-07:00</updated>
    <category term="General" label="General" scheme="http://www.nivot.org/CategoryView,category,General.aspx" />
    <category term="Monad" label="Monad" scheme="http://www.nivot.org/CategoryView,category,Monad.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://www.nivot.org/CategoryView,category,PowerShell.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.thepowershellguy.com/" target="_blank">MoW</a> poked at me, so
I guess I can’t let the crazy dutchman down:
</p>
        <p>
          <strong>How old were you when you started using computers?</strong>
        </p>
        <blockquote>
          <p>
            <em>10 or 11</em>
          </p>
        </blockquote>
        <p>
          <strong>What was your first machine?</strong>
        </p>
        <blockquote>
          <p>
            <em>An </em>
            <a href="http://en.wikipedia.org/wiki/Amstrad_CPC" target="_blank">Amstrad
CPC 464</a>
            <em>with Green screen.</em>
          </p>
        </blockquote>
        <strong>
        </strong>
        <p>
          <strong>What was the first real script you wrote?</strong>
        </p>
        <blockquote>
          <p>
            <em>I vaguely remember being delighted at having a rocket (Chr$(239)) ascend the Amstrad’s
screen when I figured out that </em>STEP –1<em> was the key in getting a for/next
loop to count backwards.</em></p>
        </blockquote>
        <p>
          <strong>What languages have you used?</strong>
        </p>
        <ul>
          <ul>
            <li>
              <em>Powershell, </em>
              <em>VBScript, JavaScript, Tcl, Perl, Batch/4NT</em>
            </li>
            <li>
Z80A, 8088/8086 (NECv20/v30) assembler 
</li>
            <li>
Basic, Turbo Pascal, Turbo C, C++, Java, C#, VB.NET</li>
          </ul>
        </ul>
        <blockquote>
          <p>
            <em>I’m a bit of a jack-of-all-trades when it comes to development. The list above
is just what I can remember ;-)</em>
          </p>
        </blockquote>
        <strong>
        </strong>
        <p>
          <strong>What was your first professional <strike>Sysadmin</strike> Developer gig?</strong>
        </p>
        <blockquote>
          <p>
            <em>After helping out a friend’s dad put together a training course for Visual Basic
3.0, I then managed to blag a job coding Ireland’s first ever major e-commerce site
using </em>
            <a href="http://docs.rinet.ru/MCIS/ch13.htm" target="_blank">
              <strong>MS
Merchant Server 1.0</strong>
            </a>
            <em> (which predated ASP 1.0) for a leading ISP.</em>
          </p>
        </blockquote>
        <strong>
        </strong>
        <p>
          <strong>If you knew then what you know now, would you have started in IT?</strong>
        </p>
        <blockquote>
          <p>
            <em>I might have started a little bit earlier even!</em>
          </p>
        </blockquote>
        <strong>
        </strong>
        <p>
          <strong>If there is one thing you learned along the way that you would tell new Sysadmins
(or Devs), what would it be?</strong>
        </p>
        <blockquote>
          <p>
            <em>Just one thing? Learn <strong>Regular Expressions</strong> as it will pay you
back ten-fold for whatever time you put into it.</em>
          </p>
        </blockquote>
        <strong>
        </strong>
        <p>
          <em>
            <strong>What is the most fun you have had scripting?</strong>
            <br />
          </em>
        </p>
        <blockquote>
          <p>
            <em>There’s only one answer here: writing extensions for PowerShell.</em>
          </p>
        </blockquote>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
This particular branch of the meme ends here as I don’t think I can tag anyone who
hasn’t been tagged already.
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=ddb76bd8-36ca-44e4-8606-45768c8bae93" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Using SharePoint Designer with .NET 3.5 SP1 Beta</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/06/12/UsingSharePointDesignerWithNET35SP1Beta.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,0c6b37fa-8428-4360-be99-1fc5db89fb7e.aspx</id>
    <published>2008-06-12T10:41:52.5958692-07:00</published>
    <updated>2008-06-12T12:55:30.2958801-07:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.nivot.org/CategoryView,category,NET.aspx" />
    <category term="SharePoint" label="SharePoint" scheme="http://www.nivot.org/CategoryView,category,SharePoint.aspx" />
    <category term="SharePoint Designer" label="SharePoint Designer" scheme="http://www.nivot.org/CategoryView,category,SharePointDesigner.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://www.nivot.org/CategoryView,category,VisualStudio.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just a quick one for the frustrated searchers out there. If you've recently installed
the SP1 beta for Visual Studio 2008 (or just the 3.5 sp1 beta alone), and you find
that you have serious difficulty using SharePoint Designer 2007 against a remote instance
of SharePoint running in a VM (or a physical machine) that <em>doesn't</em> have the
SP1 Beta bits, you know what to do. My SPD would refuse to load the master page from
my virtualized SharePoint instance until I had installed .NET 3.5 SP1 Beta onto the
virtual machine also. Just so you know!
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=0c6b37fa-8428-4360-be99-1fc5db89fb7e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Windows Mobile PowerShell Provider</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/06/06/WindowsMobilePowerShellProvider.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,3c59a56a-8af3-4e47-ac11-b018a981662d.aspx</id>
    <published>2008-06-06T04:00:15-07:00</published>
    <updated>2008-06-06T11:48:26.5205096-07:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.nivot.org/CategoryView,category,NET.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://www.nivot.org/CategoryView,category,CompactFramework.aspx" />
    <category term="Monad" label="Monad" scheme="http://www.nivot.org/CategoryView,category,Monad.aspx" />
    <category term="Pocket PC" label="Pocket PC" scheme="http://www.nivot.org/CategoryView,category,PocketPC.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://www.nivot.org/CategoryView,category,PowerShell.aspx" />
    <category term="SmartPhone" label="SmartPhone" scheme="http://www.nivot.org/CategoryView,category,SmartPhone.aspx" />
    <category term="WinCE" label="WinCE" scheme="http://www.nivot.org/CategoryView,category,WinCE.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://www.nivot.org/CategoryView,category,WindowsMobile.aspx" />
    <content type="html">&lt;p align="left"&gt;
In the spirit of "tidying things up," and pushing out nearly-there projects, I turned
my attention to &lt;a href="http://www.codeplex.com/PSMobile"&gt;http://www.codeplex.com/PSMobile&lt;/a&gt;.
I have a number of seriously annoying (to myself and people around me) habits, one
of which is having a hard time finding the motivation to get that last 1% bit of work
done. I am trying to &lt;strike&gt;kill&lt;/strike&gt; bludgeon that habit, and this is fruit
number #2 of that attempt at self-correction. I have some other important out of band
work that I need to complete, but I find I cannot concentrate on that until these
personal projects that have been niggling me for ages are dealt with. Anyway, lets
dispel a couple of questions with a screenshot:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.nivot.org/content/binary/psmobile-screenshot.png"&gt; 
&lt;/p&gt;
&lt;h3&gt;Requirements 
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
ActiveSync 4.2 or higher (or Windows Mobile Device Centre 6.0+ on Vista) &lt;a href="http://www.microsoft.com/downloads/results.aspx?pocId=&amp;amp;freetext=activesync&amp;amp;DisplayLang=en"&gt;Download&lt;/a&gt; 
&lt;li&gt;
A Windows Mobile device (PocketPC/SmartPhone 2002, 2003, 2003SE, Windows Mobile 5,
6 or 6.1) 
&lt;li&gt;
Windows PowerShell 1.0 or 2.0 (CTP) &lt;a href="http://www.microsoft.com/downloads/results.aspx?pocId=&amp;amp;freetext=powershell&amp;amp;DisplayLang=en"&gt;Download&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Features
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.nivot.org/content/binary/WindowsLiveWriter/WindowsMobilePowerShellProvider_C0D5/wm61-device_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; margin: 0px 0px 20px 20px; border-left: 0px; border-bottom: 0px" height="244" alt="wm61-device" src="http://www.nivot.org/content/binary/WindowsLiveWriter/WindowsMobilePowerShellProvider_C0D5/wm61-device_thumb.png" width="184" align="right" border="0"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div align="left"&gt;Copy, Move, Delete items between folders on your device (including
Storage Card) with standard PowerShell Cmdlets
&lt;/div&gt;
&lt;li&gt;
&lt;div align="left"&gt;Move/Copy files to/from your device and your desktop with &lt;font face="Courier New"&gt;ConvertTo-WMFile&lt;/font&gt; and &lt;font face="Courier New"&gt;ConvertFrom-WMFile&lt;/font&gt; 
&lt;/div&gt;
&lt;li&gt;
&lt;div align="left"&gt;Get device information and manipulate and explore the registry with
a rich device object returned from &lt;font face="Courier New "&gt;Get-WMDevice &lt;/font&gt;
&lt;/div&gt;
&lt;li&gt;
&lt;div align="left"&gt;&lt;font face="Courier New"&gt;Invoke-Item&lt;/font&gt; against remote items
to or execute or trigger their associated applications 
&lt;/div&gt;
&lt;li&gt;
&lt;div align="left"&gt;&lt;font face="Courier New"&gt;Invoke-Item&lt;/font&gt; with -Local switch to
attempt to execute a remote file in the context of your local desktop (e.g. office
docs or images/videos) 
&lt;/div&gt;
&lt;li&gt;
&lt;div align="left"&gt;New "Mode" attributes specific to Windows Mobile file attributes: &lt;font face="courier new"&gt;(I)nRom,
Rom(M)odule&lt;/font&gt;
&lt;/div&gt;
&lt;li&gt;
&lt;div align="left"&gt;File/Folder objects' attributes can be modified with .Attributes
properties just like &lt;font face="Courier New"&gt;FileInfos&lt;/font&gt; etc.
&lt;/div&gt;
&lt;li&gt;
&lt;div align="left"&gt;Tab completion with MoW's PowerTab &lt;a href="http://thepowershellguy.com/blogs/posh/pages/powertab.aspx" target="_blank"&gt;Download&lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;File Manipulation
&lt;/h3&gt;
&lt;p&gt;
A picture's worth a thousand words.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.nivot.org/content/binary/WindowsLiveWriter/WindowsMobilePowerShellProvider_C0D5/images-screenshot_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="571" alt="images-screenshot" src="http://www.nivot.org/content/binary/WindowsLiveWriter/WindowsMobilePowerShellProvider_C0D5/images-screenshot_thumb.png" width="663" border="0"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;h3&gt;Cmdlets and Definitions
&lt;/h3&gt;
&lt;p&gt;
Here's a table of the syntax for the included Cmdlets.
&lt;/p&gt;
&lt;table cellspacing="0" cellpadding="2" width="600" border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" align="middle" width="140"&gt;
&lt;strong&gt;Cmdlet&lt;/strong&gt;&lt;/td&gt;
&lt;td valign="top" align="middle" width="285"&gt;
&lt;strong&gt;Definition&lt;/strong&gt;&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&lt;strong&gt;WhatIf / Confirm&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
ConvertFrom-WMFile *&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Path] 
&lt;string  []&gt;
[-Destination] 
&lt;string&gt;
[-Force] [-Verbose]
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-LiteralPath] 
&lt;string  []&gt;
[-Destination] 
&lt;string&gt;
[-Force] [-Verbose]
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
ConvertTo-WMFile *&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Path] 
&lt;string  []&gt;
[-Destination] 
&lt;string&gt;
[-Force] [-Verbose]
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-LiteralPath] 
&lt;string  []&gt;
[-Destination] 
&lt;string&gt;
[-Force] [-Verbose]
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
Get-WMDeviceInfo&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Verbose] 
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
Get-WMMemoryInfo 
&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Verbose] 
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
Get-WMStoreInfo 
&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Verbose] 
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
Start-WMActiveSync 
&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Verbose] 
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
Stop-WMActiveSync&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Verbose] 
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
Start-WMProcess 
&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-LiteralPath] 
&lt;string&gt;
[[-Arguments] 
&lt;string  []&gt;
] [-Verbose]
&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="140"&gt;
Get-WMDevice&lt;/td&gt;
&lt;td valign="top" width="285"&gt;
[-Verbose]&lt;/td&gt;
&lt;td valign="top" align="middle" width="173"&gt;
&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;em&gt;* These Cmdlets that accept a path will bind to pipeline input via PSPath property
name.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
If you've got any problems, suggestions or ideas, please post into the discussions
board on the web site. Have fun!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=3c59a56a-8af3-4e47-ac11-b018a981662d" /&gt;</content>
  </entry>
  <entry>
    <title>PSEventing 1.1 For PowerShell 1.0 Final Release</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/06/06/PSEventing11ForPowerShell10FinalRelease.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,094f4f27-e830-4470-8e00-d42c45c39ed5.aspx</id>
    <published>2008-06-05T18:20:10-07:00</published>
    <updated>2008-06-05T11:25:31.3112276-07:00</updated>
    <category term="CodePlex" label="CodePlex" scheme="http://www.nivot.org/CategoryView,category,CodePlex.aspx" />
    <category term="Monad" label="Monad" scheme="http://www.nivot.org/CategoryView,category,Monad.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://www.nivot.org/CategoryView,category,PowerShell.aspx" />
    <category term="PSEventing" label="PSEventing" scheme="http://www.nivot.org/CategoryView,category,PSEventing.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I took a few hours yesterday to "tidy up my room" so to speak, so I built a nice MSI
installer, updated the help, CodePlex Wiki and examples and closed all bugs. This
is probably the final release now that PowerShell 2.0 CTP2 has introduced support
for eventing, so thanks for all the support. 
</p>
        <p>
          <strong>
            <u>New Features</u>
          </strong>
        </p>
        <ul>
          <li>
Multiple named queue support and default queue with -QueueName parameter 
</li>
          <li>
Better COM support, window message pumping etc. 
</li>
          <li>
NoFlush / Peek parameter support for queue reading 
</li>
          <li>
Get-EventQueue command added for viewing queues and their message counts. 
</li>
        </ul>
        <p>
          <strong>
            <u>Cmdlet Name Changes</u>
          </strong>
        </p>
        <ul>
          <li>
Get-Event -&gt; Read-Event 
</li>
          <li>
Connect-EventListener -&gt; Connect-Event 
</li>
          <li>
Disconnect-EventListener -&gt; Disconnect-Event 
</li>
        </ul>
        <p>
Additionally, several niggling bugs closed (including the one where read-event -wait
would return immediately with no events). 
</p>
        <p>
          <a href="http://www.codeplex.com/pseventing">http://www.codeplex.com/pseventing</a>
        </p>
        <p>
For an advanced example: <a href="http://www.nivot.org/2007/12/05/ForegroundBackgroundSwappableDownloadsInPowerShell.aspx">Foreground
/ Background Swappable Downloads In PowerShell</a>.
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=094f4f27-e830-4470-8e00-d42c45c39ed5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Background Timer PowerShell WPF Widget</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/05/23/BackgroundTimerPowerShellWPFWidget.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,bfc15b00-0444-44e3-980b-f9f8bdb32f85.aspx</id>
    <published>2008-05-23T14:04:18.164-07:00</published>
    <updated>2008-05-26T14:46:04.8873146-07:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.nivot.org/CategoryView,category,NET.aspx" />
    <category term="Monad" label="Monad" scheme="http://www.nivot.org/CategoryView,category,Monad.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://www.nivot.org/CategoryView,category,PowerShell.aspx" />
    <category term="WPF" label="WPF" scheme="http://www.nivot.org/CategoryView,category,WPF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>UPDATE May 26th</strong>: You must run PowerShell v2.0 CTP in STA mode
for this to work. Start the shell, then run "powershell -sta" from the command line
to start a new version of the shell in "single thread apartment" mode (STA). This
is required for WPF to work correctly.
</p>
        <p>
That is a bit of a mouthful of a title for this post but it's the best I could come
up with. This post takes some of <a href="http://blogs.msdn.com/powershell/archive/2008/05/22/wpf-powershell-part-1-hello-world-welcome-to-the-week-of-wpf.aspx" target="_blank">James'
scripty bits</a> and <a href="http://huddledmasses.org/wpf-from-powershell-updating-windows/" target="_blank">Jaykul's
scripty bits</a> and shows you how to create a countdown timer written in PowerShell
script that runs in the background without blocking input. Just like Jaykul's original
clock, you can drag it around and right-clicking it will close it. His version was
the current time and it also showed some system resources. I changed it into a countdown
and removed the other nested graphs. When it hits 00:00:00 it turns red. Here's what
it looks like:
</p>
        <p>
          <a href="http://www.nivot.org/content/binary/WindowsLiveWriter/BackgroundAsynchronousPowerShellWPFWidge_ED80/countdown_2.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="267" alt="countdown" src="http://www.nivot.org/content/binary/WindowsLiveWriter/BackgroundAsynchronousPowerShellWPFWidge_ED80/countdown_thumb.png" width="654" border="0" />
          </a>
        </p>
        <p>
Here's the source of invoke-background.ps1:
</p>
        <!-- Stylesheet link -->
        <link href="http://www.thecomplex.plus.com/styles/SyntaxHighlighter.css" type="text/css" rel="stylesheet" />
        <!-- Code -->
        <div class="dp-highlighter" id="hlDiv">
          <div class="bar">
          </div>
          <ol class="dp-rb">
            <li class="alt">
              <span>
                <span class="keyword">param</span>
                <span>([string]</span>
                <span class="variable">$scriptName</span>
                <span>)   </span>
              </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="comment"># original script James Brundage (blogs.msdn.com/powershell) </span>
              <span>  </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$rs</span>
              <span> = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()   </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$rs</span>
              <span>.ApartmentState, </span>
              <span class="variable">$rs</span>
              <span>.ThreadOptions
= “STA”, “ReuseThread”   </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$rs</span>
              <span>.Open()   </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="comment"># Reference the WPF assemblies </span>
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span> = {Add-Type}.GetPowerShell()   </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span>.SetRunspace(</span>
              <span class="variable">$rs</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span>.AddParameter(</span>
              <span class="string">"AssemblyName"</span>
              <span>, </span>
              <span class="string">"PresentationCore"</span>
              <span>).Invoke()   </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span>.Command.Clear()   </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span> = </span>
              <span class="variable">$psCmd</span>
              <span>.AddCommand(</span>
              <span class="string">"Add-Type"</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span>.AddParameter(</span>
              <span class="string">"AssemblyName"</span>
              <span>, </span>
              <span class="string">"PresentationFramework"</span>
              <span>).Invoke()   </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span>.Command.Clear()   </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span> = </span>
              <span class="variable">$psCmd</span>
              <span>.AddCommand(</span>
              <span class="string">"Add-Type"</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span>.AddParameter(</span>
              <span class="string">"AssemblyName"</span>
              <span>, </span>
              <span class="string">"WindowsBase"</span>
              <span>).Invoke()   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$sb</span>
              <span> = </span>
              <span class="variable">$executionContext</span>
              <span>.InvokeCommand.NewScriptBlock(   </span>
            </li>
            <li class="alt">
              <span>    (</span>
              <span class="builtin">Join-Path</span>
              <span> </span>
              <span class="variable">$pwd</span>
              <span> </span>
              <span class="variable">$scriptname</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>)   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span> = </span>
              <span class="variable">$sb</span>
              <span>.GetPowerShell()   </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$psCmd</span>
              <span>.SetRunspace(</span>
              <span class="variable">$rs</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$null</span>
              <span> = </span>
              <span class="variable">$psCmd</span>
              <span>.BeginInvoke()   </span>
            </li>
          </ol>
        </div>
        <p>
Next, here's the modified clock script:
</p>
        <div class="dp-highlighter" id="hlDiv">
          <div class="bar">
          </div>
          <ol class="dp-rb">
            <li class="alt">
              <span>
                <span class="keyword">param</span>
                <span> (   </span>
              </span>
            </li>
            <li class="">
              <span>    [timespan]</span>
              <span class="variable">$period</span>
              <span> =
(</span>
              <span class="builtin">New-Object</span>
              <span> system.TimeSpan(0,5,0)),   </span>
            </li>
            <li class="alt">
              <span>    </span>
              <span class="variable">$clockxaml</span>
              <span>=</span>
              <span class="string">"&lt;path
to xaml file&gt;\clock.xaml"</span>
              <span>  </span>
            </li>
            <li class="">
              <span>)   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="comment">### Import the WPF assemblies </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>Add-Type -Assembly PresentationFramework   </span>
            </li>
            <li class="">
              <span>Add-Type -Assembly PresentationCore   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$clock</span>
              <span> = [Windows.Markup.XamlReader]::Load(    </span>
            </li>
            <li class="alt">
              <span>         (</span>
              <span class="builtin">New-Object</span>
              <span> System.Xml.XmlNodeReader
(   </span>
            </li>
            <li class="">
              <span>            [Xml](</span>
              <span class="builtin">Get-Content</span>
              <span> </span>
              <span class="variable">$clockxaml</span>
              <span>)
) ) )   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$then</span>
              <span> = [datetime]::Now   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$red</span>
              <span> = [System.Windows.Media.Color]::FromRgb(255,0,0)   </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$redbrush</span>
              <span> = new-object system.windows.media.solidcolorbrush </span>
              <span class="variable">$red</span>
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$label</span>
              <span> = </span>
              <span class="variable">$clock</span>
              <span>.FindName(</span>
              <span class="string">"ClockLabel"</span>
              <span>)   </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$done</span>
              <span> = </span>
              <span class="variable">$false</span>
              <span>  </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="comment"># Create a script block which will update the UI </span>
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$updateBlock</span>
              <span> = {      </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="keyword">if</span>
              <span> (!</span>
              <span class="variable">$done</span>
              <span>)
{   </span>
            </li>
            <li class="">
              <span>        </span>
              <span class="comment"># update
the clock </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>        </span>
              <span class="variable">$elapsed</span>
              <span> =
([datetime]::Now - </span>
              <span class="variable">$then</span>
              <span>)   </span>
            </li>
            <li class="">
              <span>        </span>
              <span class="variable">$remaining</span>
              <span> = </span>
              <span class="variable">$null</span>
              <span>;   </span>
            </li>
            <li class="alt">
              <span>           </span>
            </li>
            <li class="">
              <span>        </span>
              <span class="keyword">if</span>
              <span> (</span>
              <span class="variable">$elapsed</span>
              <span> -lt </span>
              <span class="variable">$period</span>
              <span>)
{   </span>
            </li>
            <li class="alt">
              <span>            </span>
              <span class="variable">$remaining</span>
              <span> =
(</span>
              <span class="variable">$period</span>
              <span> - </span>
              <span class="variable">$elapsed</span>
              <span>).ToString().substring(0,8)   </span>
            </li>
            <li class="">
              <span>        } </span>
              <span class="keyword">else</span>
              <span> {   </span>
            </li>
            <li class="alt">
              <span>            </span>
              <span class="variable">$label</span>
              <span>.Foreground
= </span>
              <span class="variable">$redbrush</span>
              <span>          </span>
            </li>
            <li class="">
              <span>            </span>
              <span class="variable">$remaining</span>
              <span> = </span>
              <span class="string">"00:00:00"</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>            </span>
              <span class="variable">$done</span>
              <span> = </span>
              <span class="variable">$true</span>
              <span>  </span>
            </li>
            <li class="">
              <span>        }          </span>
            </li>
            <li class="alt">
              <span>        </span>
              <span class="variable">$clock</span>
              <span>.Resources[</span>
              <span class="string">"Time"</span>
              <span>]
= </span>
              <span class="variable">$remaining</span>
              <span>  </span>
            </li>
            <li class="">
              <span>   }   </span>
            </li>
            <li class="alt">
              <span>}   </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="comment">## Hook up some event handlers  </span>
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$clock</span>
              <span>.Add_SourceInitialized( {   </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="comment">## Before the window's even displayed
... </span>
              <span>  </span>
            </li>
            <li class="">
              <span>   </span>
              <span class="comment">## We'll create a timer </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="variable">$timer</span>
              <span> = new-object
System.Windows.Threading.DispatcherTimer   </span>
            </li>
            <li class="">
              <span>   </span>
              <span class="comment">## Which will fire 2 times every second </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="variable">$timer</span>
              <span>.Interval = [TimeSpan]</span>
              <span class="string">"0:0:0.50"</span>
              <span>  </span>
            </li>
            <li class="">
              <span>   </span>
              <span class="comment">## And will invoke the $updateBlock </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="variable">$timer</span>
              <span>.Add_Tick( </span>
              <span class="variable">$updateBlock</span>
              <span> )   </span>
            </li>
            <li class="">
              <span>   </span>
              <span class="comment">## Now start the timer running </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="variable">$timer</span>
              <span>.Start()   </span>
            </li>
            <li class="">
              <span>   </span>
              <span class="keyword">if</span>
              <span>(! </span>
              <span class="variable">$timer</span>
              <span>.IsEnabled
) {   </span>
            </li>
            <li class="alt">
              <span>      </span>
              <span class="variable">$clock</span>
              <span>.Close()   </span>
            </li>
            <li class="">
              <span>   }   </span>
            </li>
            <li class="alt">
              <span>} )   </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$clock</span>
              <span>.Add_MouseLeftButtonDown( {    </span>
            </li>
            <li class="">
              <span>   </span>
              <span class="variable">$_</span>
              <span>.Handled = </span>
              <span class="variable">$true</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="variable">$clock</span>
              <span>.DragMove() </span>
              <span class="comment">#
WPF Magic! </span>
              <span>  </span>
            </li>
            <li class="">
              <span>} )   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="variable">$clock</span>
              <span>.Add_MouseRightButtonDown(
{    </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="variable">$_</span>
              <span>.Handled = </span>
              <span class="variable">$true</span>
              <span>  </span>
            </li>
            <li class="">
              <span>   </span>
              <span class="variable">$timer</span>
              <span>.Stop()  </span>
              <span class="comment">#
we'd like to stop that timer now, thanks. </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="variable">$clock</span>
              <span>.Close() </span>
              <span class="comment">#
and close the windows </span>
              <span>  </span>
            </li>
            <li class="">
              <span>} )   </span>
            </li>
            <li class="alt">
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="comment">## Lets go ahead and invoke that update block  </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>&amp;</span>
              <span class="variable">$updateBlock</span>
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="comment">## And then show the window </span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>
              </span>
              <span class="variable">$clock</span>
              <span>.ShowDialog()   </span>
            </li>
          </ol>
        </div>
        <p>
...and finally the modified clock.xaml file:
</p>
        <div class="dp-highlighter" id="hlDiv">
          <div class="bar">
          </div>
          <ol class="dp-xml">
            <li class="alt">
              <span>
                <span class="tag">&lt;</span>
                <span class="tag-name">Window</span>
                <span> </span>
                <span class="attribute">xmlns</span>
                <span>=</span>
                <span class="attribute-value">'http://schemas.microsoft.com/winfx/2006/xaml/presentation'</span>
                <span>  </span>
              </span>
            </li>
            <li class="">
              <span>        xmlns:</span>
              <span class="attribute">x</span>
              <span>=</span>
              <span class="attribute-value">"http://schemas.microsoft.com/winfx/2006/xaml"</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>        xmlns:</span>
              <span class="attribute">system</span>
              <span>=</span>
              <span class="attribute-value">"clr-namespace:System;assembly=mscorlib"</span>
              <span>  </span>
            </li>
            <li class="">
              <span>        </span>
              <span class="attribute">WindowStyle</span>
              <span>=</span>
              <span class="attribute-value">'None'</span>
              <span> </span>
              <span class="attribute">AllowsTransparency</span>
              <span>=</span>
              <span class="attribute-value">'True'</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>        </span>
              <span class="attribute">Topmost</span>
              <span>=</span>
              <span class="attribute-value">'True'</span>
              <span> </span>
              <span class="attribute">Background</span>
              <span>=</span>
              <span class="attribute-value">"Transparent"</span>
              <span>  </span>
              <span class="attribute">ShowInTaskbar</span>
              <span>=</span>
              <span class="attribute-value">'False'</span>
              <span>  </span>
            </li>
            <li class="">
              <span>        </span>
              <span class="attribute">SizeToContent</span>
              <span>=</span>
              <span class="attribute-value">'WidthAndHeight'</span>
              <span> </span>
              <span class="attribute">WindowStartupLocation</span>
              <span>=</span>
              <span class="attribute-value">'CenterOwner'</span>
              <span> </span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">Window.Resources</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>      </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">system</span>
              <span>:String
x:</span>
              <span class="attribute">Key</span>
              <span>=</span>
              <span class="attribute-value">"Time"</span>
              <span class="tag">&gt;</span>
              <span>12:34.56</span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">system</span>
              <span>:String</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">Window.Resources</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">Grid</span>
              <span> </span>
              <span class="attribute">Height</span>
              <span>=</span>
              <span class="attribute-value">"2.2in"</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>      </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">Grid.ColumnDefinitions</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>         </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">ColumnDefinition</span>
              <span class="tag">/&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>      </span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">Grid.ColumnDefinitions</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>      </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">Label</span>
              <span> </span>
              <span class="attribute">Name</span>
              <span>=</span>
              <span class="attribute-value">"ClockLabel"</span>
              <span> </span>
              <span class="attribute">Grid.Column</span>
              <span>=</span>
              <span class="attribute-value">"2"</span>
              <span> </span>
              <span class="attribute">Opacity</span>
              <span>=</span>
              <span class="attribute-value">"0.7"</span>
              <span> </span>
              <span class="attribute">Content</span>
              <span>=</span>
              <span class="attribute-value">"{DynamicResource
Time}"</span>
              <span> </span>
              <span class="attribute">FontFamily</span>
              <span>=</span>
              <span class="attribute-value">"Impact,
Arial"</span>
              <span> </span>
              <span class="attribute">FontWeight</span>
              <span>=</span>
              <span class="attribute-value">"800"</span>
              <span> </span>
              <span class="attribute">FontSize</span>
              <span>=</span>
              <span class="attribute-value">"2in"</span>
              <span> </span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>         </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">Label.Foreground</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>            </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">LinearGradientBrush</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>               </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">GradientStop</span>
              <span> </span>
              <span class="attribute">Color</span>
              <span>=</span>
              <span class="attribute-value">"#CC064A82"</span>
              <span> </span>
              <span class="attribute">Offset</span>
              <span>=</span>
              <span class="attribute-value">"1"</span>
              <span class="tag">/&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>               </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">GradientStop</span>
              <span> </span>
              <span class="attribute">Color</span>
              <span>=</span>
              <span class="attribute-value">"#FF6797BF"</span>
              <span> </span>
              <span class="attribute">Offset</span>
              <span>=</span>
              <span class="attribute-value">"0.8"</span>
              <span class="tag">/&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>               </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">GradientStop</span>
              <span> </span>
              <span class="attribute">Color</span>
              <span>=</span>
              <span class="attribute-value">"#FF6797BF"</span>
              <span> </span>
              <span class="attribute">Offset</span>
              <span>=</span>
              <span class="attribute-value">"0.4"</span>
              <span class="tag">/&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>               </span>
              <span class="tag">&lt;</span>
              <span class="tag-name">GradientStop</span>
              <span> </span>
              <span class="attribute">Color</span>
              <span>=</span>
              <span class="attribute-value">"#FFD4DBE1"</span>
              <span> </span>
              <span class="attribute">Offset</span>
              <span>=</span>
              <span class="attribute-value">"0"</span>
              <span class="tag">/&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>            </span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">LinearGradientBrush</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>         </span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">Label.Foreground</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>      </span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">Label</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="alt">
              <span>   </span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">Grid</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
            <li class="">
              <span>
              </span>
              <span class="tag">&lt;/</span>
              <span class="tag-name">Window</span>
              <span class="tag">&gt;</span>
              <span>  </span>
            </li>
          </ol>
        </div>
        <p>
Important: you'll need to save all files into the same directory and fix up the path
to the clock.xaml file in the start-countdown.ps1 script.
</p>
        <p>
Have fun!
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=bfc15b00-0444-44e3-980b-f9f8bdb32f85" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Cmdlet name clashes in PowerShell: What to do?</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/05/21/CmdletNameClashesInPowerShellWhatToDo.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,fbb68597-10f7-4ee3-b1be-56eb913f5fae.aspx</id>
    <published>2008-05-21T05:36:39.7544729-07:00</published>
    <updated>2008-05-21T05:36:39.7544729-07:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.nivot.org/CategoryView,category,NET.aspx" />
    <category term="Monad" label="Monad" scheme="http://www.nivot.org/CategoryView,category,Monad.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://www.nivot.org/CategoryView,category,PowerShell.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This question has been asked in various ways over the last few years and I don't believe
an answer that suits everyone has been proffered yet. I think this is part of a broader
problem space that needs to be solved, one that I (and many others) have spent a bit
thinking about -- for me personally, it's been mostly in the pub strangely enough,
usually with a pint in hand -- and while I don't profess to have the answer, I do
spent most of my powershell time tinkering with providers and have some views on this
;-)
</p>
        <p>
Firstly, if you haven't seen this suggestion I've raised on connect (<a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=344643&amp;SiteID=99&amp;wa=wsignin1.0">Allow
providers other than the filesystem provider to surface commands</a>) then take a
gander at it now. It suggests allowing providers other than the FileSystemProvider
to surface commands by using a new ProviderCapabilities flag. For those not able to
read this suggestion, the bottom line is that currently one can execute a command
on the filesystem by using the following syntax:
</p>
        <p>
          <font face="Courier New">ps c:\&gt; .\test.bat<br />
hello, world</font>
        </p>
        <p>
However, if you had another provider that linked into a mobile device, the amazon
s3 service or MSL skydrive (when are they going to release an API?) for example, you
would allow execution of commands with the same syntax, e.g.
</p>
        <p align="left">
          <font face="courier new">ps skydrive:\&gt; cd ppts<br />
ps skydrive:\ppts&gt; .\mydemo.ppt<br />
The term '.\mydemo.ppt' is not recognized as a cmdlet, function, operable program,
or script file. Verify the term and try again.<br />
At line:1 char:8<br />
+ .\mydemo.ppt &lt;&lt;&lt;&lt;</font>
        </p>
        <p>
As you can see, this doesn't work. 
</p>
        <p>
What's important is having the same experience with similarly capable providers; e.g.
those that can host executable content. Yes, you can implement support for invoke-item,
but it's a bit discordant. One of the nicest features of powershell (and sometimes
the most confusing) is that all providers - variable, function, environment, filesystem
etc all hook into the same framework. There are some philosophically irksome differences
like the fact that the  variable drive is the "default" provider, since dollar-qualified
expressions are assumed to point there if not qualified with a drive name:
</p>
        <p align="left">
          <font face="courier new">ps c:\&gt; $host<br />
Name             : ConsoleHost<br />
Version          : 1.0.0.0<br />
InstanceId       : 9d8a29bf-3d84-4ce6-8651-e0c72afb404b<br />
UI              
: System.Management.Automation.Internal.Host.InternalHostUserInterface<br />
CurrentCulture   : en-CA<br />
CurrentUICulture : en-US<br />
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy </font>
        </p>
        <p>
so let's give a drive name this time:
</p>
        <p align="left">
          <font face="courier new">ps c:\&gt; ${c:test.bat}<br />
@echo hello, world</font>
        </p>
        <p>
This is a lot easier to understand once you realise that the '$' prefix is a grammatical
shortcut into the IContentReader/IContentWriter interfaces on every provider; Much
easier than just blindly committing to memory the method to read a variable and the
method to read a file (imho). Once you introduce this capability into other providers,
you then have to address ye olde $env:path variable. Currently this variable is imported
from the system environment. The system, aka Windows, knows nothing about powershell
and its drives. When using Get-Command, the search order for discovering commands
is:
</p>
        <p>
Aliases, Functions, Cmdlets, Scripts, Commands located in the directories specified
by the Path environment variable, External scripts.
</p>
        <p>
As we can see, Commands (5) are discovered via the $env:path variable. The other items
(apart from 3 - cmdlets) all live in a flat namespace, so there's no path involved
there.  I'd love if somehow it were possible to add any powershell path to this
variable, even if they were limited to drive-qualified paths:
</p>
        <p>
          <font face="courier new">ps c:\&gt; $env:path<br />
c:\windows; c:\windows\system32; ...; s3:\utilities; "mobile:\storage card"; ...</font>
        </p>
        <p>
Perhaps this information could be persisted inside PowerShell only so when the shell
is exited, the path environment variable remains unchanged when viewed from the external
windows system. This might mean that PowerShell paths would have to be appended in
your profile at each load, but this isn't a bad thing either, IMO. So finally, on
to the crux of the matter: disambiguation of identically named Cmdlets. Ultimately
I don't believe there is a magic answer. This is solved in Windows by using the path
variable, and so I believe it isn't such a bad idea to solve it with a path variable
in powershell too. Behold <strong>$env:cmdletpath</strong></p>
        <p align="left">
          <font face="courier new">ps c:\&gt; $env:cmdletpath<br />
Microsoft.PowerShell.Core; Microsoft.PowerShell.Host; Microsoft.PowerShell.Management;
Microsoft.PowerShell.Security; Microsoft.PowerShell.Utility; VMWare.Commands.Utility</font>
        </p>
        <p>
It's simple. It's optional. Snap-in qualified commands would continue to work, overriding
the cmdlet search path. Instead of having to alias multiple commands when using a
snapin that replaces a suite of built-in cmdlets, you can just re-jig the search path.
Done. It's not the answer to everything, but it sure would make life a bit easier,
no?
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=fbb68597-10f7-4ee3-b1be-56eb913f5fae" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Visual Studio 2008 + .NET 3.5 SP1 Beta Experiences</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/05/20/VisualStudio2008NET35SP1BetaExperiences.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,cc05d59c-817b-4f4d-ae68-683d01029d4b.aspx</id>
    <published>2008-05-20T07:30:14.212316-07:00</published>
    <updated>2008-05-20T07:30:14.212316-07:00</updated>
    <category term=".NET" label=".NET" scheme="http://www.nivot.org/CategoryView,category,NET.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://www.nivot.org/CategoryView,category,VisualStudio.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have two machines at home here, one is a Vista SP1 laptop, the other an XP SP3 Desktop.
The latter was recently patched with SP3 in a desperate attempt to prolong its dwindling
desire to function in a reasonable fashion. It's what I call from a development box
point of view, "Encrusted." Encrustation is the point at which you no longer have
any idea what beta, CTP, evaluation or otherwise not recommended software is installed.
It defies its digital nature by throwing up different errors each time its booted.
Anyway, the SP1 Beta would not install on this machine, specifically the .NET 3.5
beta bits. I may investigate further, but frankly I think it's time for <em>fenestrecide </em>and
a corresponding rebirth<em>.</em></p>
        <p>
This led me to try updating my Vista laptop instead. If you download the VS2008 patch
you'll notice it's only about 450KB. It's a stub which detects what's missing from
your environment and downloads only what it needs. I found the installer to be extremely
useless in terms of giving feedback over what it was doing. It just says "installing"
and you have to watch a progress bar slowly creeping across with many stalls where
your machine doesn't seem to be doing anything at all. This time I downloaded the
separate .NET 3.5  SP1 beta bits which size about 220MB. I installed this first
and it seemed to go OK. Next, I downloaded the VS patch and let it go ahead. Again
many stalls where you're wondering if it's actually going to work at all. Eventually,
it failed. After some examination of the logs, I discovered that it didn't like the
post-RTM patches for supporting the Reference Source server ( <a title="Shawn Burke's Blog - Configuring Visual Studio to Debug .NET" href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx">Shawn
Burke's Blog - Configuring Visual Studio to Debug .NET</a> ). After removing these
updates, I was able to progress to past this prior point of failure but by this time
it was midnight, having started the process in earnest at around 8pm. I decided to
leave it to run overnight.
</p>
        <p>
In the morning I had a stalled install process and a dialog notifying me that files
were in use and that I should shutdown "Machine Debug Manager," "Windows Sidebar Component"
and "Windows Sidebar" - Vista GUI cruft - if I wanted to avoid a reboot. I stopped
the MDM service and shutdown Windows Sidebar and chose "Retry" from the options of
"Retry," "Cancel" and "Ignore." Even though I hit "Retry," the bland dialog displaying
"installing" now switched to "Installation failed.. rolling back" - but thankfully,
it was NOT rolling back. The status bar appeared stalled for about 10 minutes then
popped up the same dialog, this time with only "Windows Sidebar" listed. This time
I chose "Ignore" implicitly accepting the penalty of a reboot to allow the status
bar to continue its inexorable journey to the right, all the time the text telling
me that the installation had failed and it was rolling back. Ten more minutes and
the install succeeded. To summarise, VS seems snappier, and everything seems to work
fine. I'll post more if I discover anything of interest.
</p>
        <p>
The usual suspects have more information:
</p>
        <p>
          <a title="Beta of .NET 3.5 and VS2008 SP1 is out" href="http://weblogs.asp.net/scottgu/archive/2008/05/12/visual-studio-2008-and-net-framework-3-5-service-pack-1-beta.aspx">Beta
of .NET 3.5 and VS2008 SP1 is out</a> (Scott Guthrie)
</p>
        <p>
          <a title="VS2008 and .Net 3.5 SP1 Beta - Should You Fear This Release-" href="http://www.hanselman.com/blog/VS2008AndNet35SP1BetaShouldYouFearThisRelease.aspx">VS2008
and .Net 3.5 SP1 Beta - Should You Fear This Release-</a> (Scott Hanselman)
</p>
        <p>
          <a title=".NET 3.5 SP1 Beta- Changes Overview" href="http://codebetter.com/blogs/patricksmacchia/archive/2008/05/13/net-3-5-sp1-beta-changes-overview.aspx">.NET
3.5 SP1 Beta- Changes Overview</a> (Patrick Smacchia)
</p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=cc05d59c-817b-4f4d-ae68-683d01029d4b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>PowerShell 2.0 CTP2 Problems with WinRM: Access is Denied</title>
    <link rel="alternate" type="text/html" href="http://www.nivot.org/2008/05/09/PowerShell20CTP2ProblemsWithWinRMAccessIsDenied.aspx" />
    <id>http://www.nivot.org/PermaLink,guid,019680d9-f1a8-4210-bdb1-b49e1a4ccfd3.aspx</id>
    <published>2008-05-08T18:57:30.9724227-07:00</published>
    <updated>2008-05-08T18:57:30.9724227-07:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
After installing the new <a href="https://connect.microsoft.com/Downloads/Downloads.aspx?SiteID=200" target="_blank">WinRM
2.0</a> and <a href="http://go.microsoft.com/fwlink/?LinkID=107395" target="_blank">PowerShell
2.0 CTP</a> bits onto my Vista/SP1 laptop, I kept getting "Access is denied" messages
continually while running the "Configure-WSMan.ps1" script. Fellow MVP Richard Siddaway
discovered that disabling UAC seemed to clear up the problem for him, but this is
not really a good solution. I want to keep UAC enabled. It turns out also that another
precondition for this error is that your machine is <strong>not</strong> joined to
a domain or <strong>is</strong> in a workgroup/standalone. After some communication
with the PowerShell team, who in turn talked to the WinRM team, it appears that some
additional configuring is needed for machines in this situation:
</p>
        <blockquote>
          <p align="left">
            <em>If the account on the remote computer has the same logon username and password,
the only extra information you need is the transport, the domain name, and the computer
name. Because of </em>
            <a href="http://go.microsoft.com/FWLink/?LinkId=84438">
              <em>User
Account Control (UAC)</em>
            </a>
            <em>, the remote account must be a domain account and
a member of the remote computer Administrators group. If the account is a local computer
member of the Administrators group, then UAC does not allow access to the WinRM service.
To access a remote WinRM service in a workgroup, UAC filtering for local accounts
must be disabled by creating the following DWORD registry entry and setting its value
to 1: <b>[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System] LocalAccountTokenFilterPolicy</b>.</em>
          </p>
        </blockquote>
        <p align="left">
This is taken from <a href="http://msdn.microsoft.com/en-us/library/aa384423.aspx">http://msdn.microsoft.com/en-us/library/aa384423.aspx</a></p>
        <p align="left">
This information can also be found buried in one of PowerShell 2.0's help files, accessed
via: 
</p>
        <p align="left">
          <font face="Courier New" size="3">ps&gt; get-help about_remote_faq | more</font>
        </p>
        <img width="0" height="0" src="http://www.nivot.org/aggbug.ashx?id=019680d9-f1a8-4210-bdb1-b49e1a4ccfd3" />
      </div>
    </content>
  </entry>
</feed>