Prof. Powershell

Prof. Powershell: Provider Peek

PSDrives work like real drives, only differently. Here's how to work with these PSProviders in PowerShell.

You're probably familiar with PSDrives in PowerShell. These "drives" usually present hierarchical systems, like the registry, as any other drive that you can navigate using common commands like DIR:

PS C:\> dir hklm:\system\currentcon 
trolset\services\spooler

The element that makes this possible is referred to as a PSProvider. PSProviders are bundled with PowerShell snap-ins and installed by default when you load the snap-in. When you run the Get-PSDrive cmdlet, you'll see all mapped PSDrives.

Notice the Provider column? What are these things? To answer that question, we'll use a cmdlet called Get-PSProvider:

PS C:\> get-psprovider

This cmdlet will show all currently loaded PSProviders. If you have a snap-in installed but not currently loaded into your PowerShell session, you won't see any PSProviders included in that snap-in until you load it. Or you can look at the details for a specific provider:

PS C:\> get-psprovider registry | select *
ImplementingType : Microsoft.PowerShell.Commands.RegistryProvider
HelpFile : System.Management.Automation.dll-Help.xml
Name : Registry
PSSnapIn : Microsoft.PowerShell.Core
Description :
Capabilities : ShouldProcess
Home :
Drives : {HKLM, HKCU}

The most important information that Get-PSProvider supplies is the provider's capabilities. As you work with cmdlets like Get-ChildItem, you'll notice that they may behave differently based on the PSDrive. For example, you can use the -filter parameter when searching a local drive, but not when searching the registry; you'll get an error message that filtering isn't supported. If you look at the capabilities of the Registry PSProvider, you'll notice that Filter is not included. It's up to the provider developer to decide what capabilities to include.

As you're exposed to new PowerShell snap-ins and even PowerShell 2.0, you'll see additional PSProviders with some very snazzy capabilities. But remember that even though a PSProvider offers a particular capability, it's up to the cmdlets you use to take advantage of them.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

Featured

  • Microsoft Releases Windows 10 Version 1909

    Microsoft on Tuesday announced the release of Windows 10 version 1909, a new operating system product that's also known as the "Windows 10 November 2019 Update."

  • November Microsoft Security Bundle Addresses 75 Vulnerabilities

    Of that number, 13 vulnerabilities are rated "Critical" to patch, while 62 vulnerabilities are deemed "Important."

  • The Future of Office 365 Pricing

    With a raft of new Office 365 features in the pipeline, Microsoft also seems ready to change the way it bills its subscribers. Will it replicate Azure's pay-per-use model, or will it look like something else entirely?

  • Microsoft Offers 1 Year of Free Windows 7 Extended Security Updates to E5 Licensees

    Microsoft is offering one year of free support under its Extended Security Updates program to Windows 7 users if their organizations have E5 licensing.

comments powered by Disqus

Office 365 Watch

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.