Howto: Write a PowerShell Drive Provider
21 June 2007 in Code, Tools | Comments enabled

Earlier this year I was tooling around with PowerShell and generally having a fun time with it and, based on a comment from Andrew, decided to see how difficult it would be to write a PowerShell Drive Provider. A drive provider is a mechanism of allowing you to navigate any store with the same commands as navigating the file system. PowerShell ships with several providers already, a registry and certificate store. This means you are able to “cd” into your registry and write commands like “dir” or “ls” on a node and get a list of all the children for example.

The attached download includes working commented code and a detailed tutorial PDF on how to write a drive provider that will enable you to mount a zip file as a drive and then navigate through it. This is powerful for removing the need to extract and then navigate files quickly and easily. I’ve implemented it in a simplistic manner and there is plenty of room for additional features but I wanted to keep it simple for educational purposes. Note that you will need PowerShell installed to even compile as it relies on several assemblies that ship with PowerShell.

So if you find yourself lying awake at night wishing you could mount zip files as drives within PowerShell (don’t we all?) or just want to learn more about writing drive providers or managed plug-ins for PowerShell then check this out.

Download the PowerShell Zip Drive Provider and Tutorial

Hope this helps people have more of a poke at PowerShell,

– JD


2 comments. Add your own comment.

Kirk Jackson says 21 June 2007 @ 22:05

Good timing for PS Drive Providers. The PowerShell team blog has just posted one that lets you ‘cd’ into your database:
http://blogs.msdn.com/powershell/archive/2007/06/21/demo-sql-provider-code.aspx

Must be time for a Lightspeed one (not that I’m sure how that would even work :)

Kirk

traskjd says 24 June 2007 @ 17:30

Thanks Kirk :)

Yeah, if I could work out a way of applying LS to one I would :)

Cheers,

– JD

Leave a Comment

Name (required)

E-mail (required - not published)

Website

Your comment: