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 [...]
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 [...]
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 [...]
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 [...]
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 [...]
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 objects, [...]
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 [...]
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, [...]
Writing your own PowerShell Hosting App (Part 1. Introduction)
I’ve mentioned before that I use a homegrown PowerShell host in my work. I have been more than pleasantly surprised at how easy and how rewarding this is. In the last few weeks, I’ve seen a few articles that have gotten me thinking about writing a series of blog posts about how to get started. [...]
Is it just me? (Or does PowerShell remind you of SQL?)
When preparing a PowerShell training class for a group of DBAs, I realized that there were some parallels between basic SQL and basic PowerShell commands. A (very) basic SQL statement has the form: SELECT <COLUMNS> FROM <TABLE> WHERE <CONDITION> ORDER BY <EXPRESSION> I noticed that a very common idiom for PowerShell pipelines* was: <data source [...]