Providers and PSDrives
A provider exposes some hierarchical store as though it were a filesystem. Once it does, the same commands work against it: Get-ChildItem, Get-Item, Set-Location, Test-Path, Remove-Item.
Documentation: Microsoft Learn
Overview
Windows PowerShell ships providers for the filesystem, the registry, certificates, environment variables, functions, aliases and variables. So Get-ChildItem HKLM:\Software lists registry keys, Get-ChildItem Cert:\LocalMachine\My lists certificates, and Get-ChildItem Env: lists environment variables. You did not learn new commands for any of those.
Get-PSDrive lists the drives each provider offers. C: is a filesystem drive, HKLM: is a registry drive, Cert: is a certificate drive. New-PSDrive adds your own, which is a tidy way to give a long UNC path a short name for the session.
The catch is that output columns change with the provider, because the objects are different. A file has Length and LastWriteTime; a registry key has Property and SubKeyCount. Same cmdlet, different objects, so pipe to Get-Member when you move to an unfamiliar drive.
What happens
Get-PSDrive returns one object per drive with the provider that backs it and the root it maps to. Reading the Provider column is the fastest way to see that C: and HKLM: are the same kind of thing as far as PowerShell is concerned, which is what makes the file commands work on the registry.
Worth remembering
- Providers make stores look like drives, so file commands work on them.
- Get-ChildItem works on HKLM:, Cert: and Env: as well as C:.
- Get-PSDrive lists drives. New-PSDrive adds one.
- Output columns differ by provider because the objects differ.
Primary documentation
Try it
Browser simulation · fictional data; no changes to your computer.
Follow the objects
Run the command to inspect each stage.
Lists the drives available in this session and which provider backs each.
Show reference output
Browser dataset output · the real environment will differ
Name Provider Root -------- ----------- ------------------ C FileSystem C:\ D FileSystem D:\ HKCU Registry HKEY_CURRENT_USER HKLM Registry HKEY_LOCAL_MACHINE Env Environment Function Function Variable Variable Alias Alias
Practise this
Find your working directory
Display the current location as a Path object.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.