What is psprovider in powershell?

3

I am new to PowerShell and trying to understand the concept of psprovider. I know I can use Get-PSProvider to show a list of available psproviders

All of the help I am finding, assumes I know things that I don't. Looking for a basic explanation of psprovider.

James Jenkins

Posted 2016-04-15T13:10:17.357

Reputation: 500

Answers

4

This is from the help file for Get-PSProvider:

Among other things, Windows PowerShell providers determine which 
data stores you can navigate through.

There are two major concepts buried in here. The first is the concept of a data store or, if you like, a container. The second is the concept of navigating.

The concept of data store is basic to operating on data. If you've done any work with scripting or programming, you're familiar with variables. In fact, variables are one of the kinds of data stores listed by Get-PSProvider. If you've done any work with databases or websites, you're familiar with other kinds of data stores. A second kind of navigable data store listed for you is a file system. If you've done any work with Windows, you're familiar with folders and files, and even with navigating through folders and subfolders. Folders are called directories in Powershell, but it's the same concept.

The Registry is a different kind of data store.

What's new to me, and perhaps to you, is the idea of generalizing all of these different kinds of data stores into a general superclass, and then defining certain operations on the entire superclass.

For example, Get-ChildItem is a basic navigation operation that allows you to traverse a tree of containers arranged in a hierarchy. But instead of implementing a specialized GCI for files, and another one for Registry entries, and another one for variables, and so on, they chose to implement a single GCI that could be adapted for use with any of those three, and several others.

This is just the beginning of the concepts, but I hope it helps.

Walter Mitty

Posted 2016-04-15T13:10:17.357

Reputation: 419

3

PSProviders are basically data stores. you can handle those like a normal datasystem folder. get-psproviders will get you a list of all the psproviders.

example: with cmd.exe it was not possible to change your current location to the Registry. you had the possibility to change registry settings with cmd, but you can not handle it like a directory or cd to the registry.

in PowerShell, the Registry is a PSProvider. means you can access it like a datasystem folder. if you type cd hklm: you're actually inside the local machine registry, and can access its content with Get-ChildItem

this has the advantage that you can provide for example PSDrives which actually point into the registry.

New-PSDrive -name G -PSProvider Registry -Root HKCU:\Software

The G:\ Drive is now mapped to the Current User > Software Registry. (only for the current PSSession)

There are a lot of functionalities you can do with PSProviders. you should execute and read get-help about_providers for further information.

SimonS

Posted 2016-04-15T13:10:17.357

Reputation: 4 566