Cleaning the Path – A PowerShell One-liner

I’m not super crazy about writing one-liners in PowerShell, but I ran across a fun problem which was quick to write as a one-liner.  I’ll give that here with a little explanation, and follow up in a couple of days with a more polished advanced function solution. Anyway, the problem was that I was working …

Continue reading ‘Cleaning the Path – A PowerShell One-liner’ »

The PowerShell Bug That Wasn’t, and More Package Management

Have you ever tracked down a bug, been confident that you had found the root of your problems, only to realize shortly afterwords that you missed it completely? What I posted yesterday as a bug in PowerShell (having to do with recursive functions, dot-sourcing, and parameters) seemed during my debugging session to clearly be a …

Continue reading ‘The PowerShell Bug That Wasn’t, and More Package Management’ »

Package Management and a PowerShell Bug

UPDATE: I have worked out how the behavior described at the end of this post is not a bug, but in fact just PowerShell doing what it’s told. Don’t have time to explain right now, but I’ll write something up later today. I also worked out how to “fix” the behavior. For a long time …

Continue reading ‘Package Management and a PowerShell Bug’ »

Writing your own PowerShell Hosting App (the epilog)

As I mentioned before, I have created a CodePlex project to track the development of a WPF PowerShell host using AvalonDock and AvalonEdit. It’s still in the very beginning stages, but it’s comparable to the code I used in this tutorial series (except that it’s using different technologies, all of which I’m new to). PowerShellWorkBench …

Continue reading ‘Writing your own PowerShell Hosting App (the epilog)’ »

Writing your own PowerShell Hosting App (part 6…the final episode)

Before we proceed with putting powershell objects in a treeview (which I promised last time), I need to explain some changes I have made to the code. Refactoring the InvokeString functionality ouf of the menu item event Merging the error stream into the output stream Replacing the clear-host function with a custom cmdlet First, we …

Continue reading ‘Writing your own PowerShell Hosting App (part 6…the final episode)’ »

Writing your own PowerShell Hosting App (part 5)

In the last post, we got to the point that we were actually using the new host objects that we implemented, but we still hadn’t provided anything more than trivial implementations (throwing an exception) for the methods that make a custom host useful, e.g. the write-* functions. Before we do that, we need to discuss …

Continue reading ‘Writing your own PowerShell Hosting App (part 5)’ »

Writing your own PowerShell Hosting App (Part 4)

WARNING:  This is a long post with lots of code!  🙂 In the last post, we got to the point that we ran into the limitatoin of simply running scripts through a bare runspace. You can accomplish quite a bit, but to have the full shell experience, you’ll want to actually create a the host …

Continue reading ‘Writing your own PowerShell Hosting App (Part 4)’ »

Writing your own PowerShell Hosting App (Part 3)

In the last post we started building the app, but ran into a problem with output.   We were able to get output from some scripts (dir, for example, gave incomplete output), but others didn’t give us anything useful at all (get-service, returned “System.ServiceProcess.ServiceController” over and over). The reason for this is simple.  PowerShell cmdlets (and …

Continue reading ‘Writing your own PowerShell Hosting App (Part 3)’ »

Writing your own PowerShell Hosting App (Part 2)

In the last post, I discussed some of the reasons why you might want to write your own PowerShell hosting app.  I realized later that I didn’t define what that meant. In general, there are 2 ways to include PowerShell technology in an application. Use the PowerShell objects (in the System.Management.Automation.* namespaces) to execute scripts, …

Continue reading ‘Writing your own PowerShell Hosting App (Part 2)’ »