In this tutorial we will go though PowerShell Providers. We will see which are the default providers in Windows PowerShell and how we are able to import and remove providers from a session. Microsoft describes PowerShell Providers as below:
PowerShell providers are Microsoft .NET Framework-based programs that make the data in a specialized data store available in PowerShell so that you can view and manage it.
You can access the data in a provider the same way like accessing files in your data drive. Each provider supports all Windows PowerShell core set of commands that are included by default. Those commands are provided in “PowerShell Core Commands” tutorial. A provider may have also custom commands only for the specific provider that you can use with it. Also some parameters may be available on existing commands that you are allowed to use them with the specific provider only.
Below is a list of the built-in providers in Windows PowerShell.
- Data Store: PowerShell Aliases
- Data Store: x509 Certificates for Digital Signatures
- Data Store: Windows Environment Variables
- Drive: (*)
- Data Store: File System Drives, Directories and Files
- Data Store: PowerShell Functions
- Data Store: Windows Registry
- Data Store: PowerShell Variables
- Data Store: WS-Management Configuration Information
During a session you are able to create your own provider. To create a provider you need to
Find the loaded PowerShell Providers
In order to see the current providers that are loaded in your current session you need to used the following command:
Adding and Removing Providers
Adding a Provider
The providers, except of the built-in ones which are loaded by default, are added / installed in Windows PowerShell when you import a module in the current session. In the example below you can see that I import ActiveDirectory module into my session and when I check the loaded providers, I can see the provider for Active Directory.
Get-PSProvider Import-Module ActiveDirectory Get-PSProvider
Removing a Provider
If we want to remove a provider from our current session, there are two ways to do it. The first one is to remove the module from the current session. If you remove the module then the provider will be removed also. You can remove the module by using the below command.
Get-PSProvider Remove-Module ActiveDirectory Get-PSProvider
The other way to remove a provider is to remove the drive associated with. Basically, this method will remove the drive but will not affect the data within the drive. It will make the drive unavailable. You can do so by using the following command.
Get-PSPsrovider Remove-PSDrive -Name "AD" Get-PSProvider
You are able to set Home for the providers. The only provider that has a default value for Home is FileSystem. All other providers have nothing as a default value but you can set it yourself. To provide a home directory for a provider you need to use the Home property of the provide. The below examples are showing the change of Home for FileSystem and Registry providers.
Get-PSProvider | Format-Table Name, Home (Get-PSProvider FileSystem).Home = 'C:\' Get-PSProvider | Format-Table Name, Home (Get-PSProvider Registry).Home = 'HKLM:\' Get-PSProvider | Format-Table Name, Home
Provider related cmdlets
Below I am providing you once again the related cmdlets for PowerShell Providers. More information about those commands you can find in the section below with related links.
- ChildItems cmdlets
- Content cmdlets
- Item cmdlets
- ItemProperty cmdlets
- Location cmdlets
- Path cmdlets
- PSDrive cmdlets
- PSProvider cmdlets
I hope the tutorial about PowerShell Providers is helpful.
Please let me know your comments and thoughts.
You feedback is appreciated.
- PowerShell Scripts
- PowerShell Tutorials
- PowerShell Core Commands
- about_Core_Commands | Microsoft Docs
- about_Providers | Microsoft Docs
- Import-Module – Microsoft Docs
- Get-ChildItem – Microsoft Docs
- Add-Content – Microsoft Docs
- Clear-Content – Microsoft Docs
- Get-Content – Microsoft Docs
- Set-Content – Microsoft Docs
- Clear-Item – Microsoft Docs
- Copy-Item – Microsoft Docs
- Get-Item – Microsoft Docs
- Invoke-Item – Microsoft Docs
- Move-Item – Microsoft Docs
- New-Item – Microsoft Docs
- Remove-Item – Microsoft Docs
- Rename-Item – Microsoft Docs
- Set-Item – Microsoft Docs
- Clear-ItemProperty – Microsoft Docs
- Copy-ItemProperty – Microsoft Docs
- Get-ItemProperty – Microsoft Docs
- Move-ItemProperty – Microsoft Docs
- New-ItemProperty – Microsoft Docs
- Remove-ItemProperty – Microsoft Docs
- Rename-ItemProperty – Microsoft Docs
- Set-ItemProperty – Microsoft Docs
- Get-Location – Microsoft Docs
- Pop-Location – Microsoft Docs
- Push-Location – Microsoft Docs
- Set-Location – Microsoft Docs
- Join-Path – Microsoft Docs
- Convert-Path – Microsoft Docs
- Split-Path – Microsoft Docs
- Resolve-Path – Microsoft Docs
- Test-Path – Microsoft Docs
- Get-PSDrive – Microsoft Docs
- New-PSDrive – Microsoft Docs
- Remove-PSDrive – Microsoft Docs
- Get-PSProvider – Microsoft Docs