Creating a PowerShell Navigation Provider: Introduction
PowerShell has some really nice ways that it can be extended. One of those ways is via Providers. If you open up PowerShell and call Get-PSDrive
you will see a list of the drives on your machine along with some other providers to access things like the registry, certificate stores, and aliases. Using these providers is very similar to navigating a normal drive, for example, I can navigate around the registry by simply typing cd HKCU:
. Now I can see items in the registry by typing dir
and I see items in my registry (I used dir | Format-Table -Property Name
for brevity):
Name
----
HKEY_CURRENT_USER\AppEvents
HKEY_CURRENT_USER\Console
HKEY_CURRENT_USER\Control Panel
HKEY_CURRENT_USER\Environment
HKEY_CURRENT_USER\EUDC
HKEY_CURRENT_USER\Identities
HKEY_CURRENT_USER\Keyboard Layout
HKEY_CURRENT_USER\Network
HKEY_CURRENT_USER\Policies
HKEY_CURRENT_USER\Printers
HKEY_CURRENT_USER\Software
HKEY_CURRENT_USER\System
HKEY_CURRENT_USER\WXP
HKEY_CURRENT_USER\Volatile Environment
Navigating these items is now as easy as using cd
to change directories. So cd Software\Microsoft\Windows\CurrentVersion
takes me into that node within the registry. From here you can now use other commands to update the registry. As you can see, this is a convenient way to access data in the registry and since it is inside of PowerShell, it can all be scripted.
Creating a basic PowerShell provider is a relatively simple task. Over the next few blog posts, I will walk through the basics of creating a Navigation Cmdlet Provider, so you can add your own custom drive to PowerShell.