liveBook · Manning

Provider

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

The FileSystem provider is a PowerShell provider that exposes the local file system through PowerShell drives and item cmdlets.

A provider is an adapter that makes a data store look like a PowerShell drive. The FileSystem provider exposes files and folders through drives such as /, and generic item cmdlets manage what the drive contains. section 5.1

PS C:\Scripts\ > Get-PSProvider
Name                 Capabilities                              Drives
----                 ------------                              ------
Alias                ShouldProcess                             {Alias}
Environment          ShouldProcess                             {Env}
FileSystem           Filter, ShouldProcess, Credentials        {/}
Function             ShouldProcess                             {Function}
Variable             ShouldProcess                             {Variable}

Inspect installed providers with Get-PSProvider. The FileSystem provider advertises Filter, ShouldProcess, and Credentials capabilities, while other providers expose different operations. section 5.1

Work with a FileSystem provider by combining locations, paths, and item cmdlets:

  • Use Set-Location, or its cd alias, to move to a folder. Windows can use paths such as C:\Users\name; Linux and macOS use a single root such as /. section 5.3
  • Use Get-ChildItem to list contents, and use Item verbs such as New, Copy, Move, Remove, Rename, and Set to manage files and folders. section 5.1 section 5.2
  • Specify -Path for wildcard matching, where * matches zero or more characters and ? matches one character; use -LiteralPath when those characters belong to the name. section 5.4
  • Tell New-Item what to create: New-Item testFolder -ItemType Directory creates a directory, while a generic command may prompt because the item type is unknown. section 5.3

Create and inspect a directory

New-Item -Path ~/Labs -ItemType Directory Set-Location ~/Labs New-Item -Name Test.txt -ItemType File Get-ChildItem These commands create a directory, create a zero-length file, change location, and list the resulting filesystem items. section 5.6 section 5.7

Generic cmdlets do not guarantee that every provider supports every operation. The FileSystem provider lacks Transactions support, and Set-Item cannot change a file's contents; item properties and provider capabilities determine what is valid. section 5.2 section 5.7

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains the adapter, drive, capabilities, navigation, wildcards, and item commands, but stops short of provider implementation internals.
Examples
Uses Get-PSProvider, Get-PSDrive, filesystem navigation, wildcard paths, New-Item, and a cross-platform provider lab.
What it assumes
Assumes basic filesystem familiarity while teaching provider, PSDrive, item noun, capability, and cross-platform path concepts.
What you can do after
Operate/configure filesystem locations and items with PowerShell drives, navigation commands, wildcard paths, and generic item cmdlets.
How it connects
Connects providers with PSDrives, item cmdlets, paths, wildcards, item properties, and provider capabilities.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.