liveBook · Manning

Drive

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

A PSDrive is a PowerShell drive abstraction that provides access to a filesystem or another provider-backed data store.

A PSDrive is a PowerShell drive abstraction that exposes a filesystem or another provider-backed data store through a drive-like path. A provider adapts the data store, while the PSDrive makes it accessible to PowerShell commands. section 5.0 section 5.1

Use these commands to inspect drives and work with their contents:

  • Run Get-PSDrive to list available drives, including filesystem, environment, alias, function, and variable drives. section 5.1
  • Use generic item cmdlets such as Get-Item, Get-ChildItem, New-Item, Copy-Item, Move-Item, and Remove-Item. section 5.1 section 5.2
  • Change the current location with Set-Location or its cd alias, using paths appropriate to the operating system. section 5.3

Use a non-filesystem drive

The Environment provider is available across systems. List environment variables with Get-ChildItem env:*; create variable A with Set-Item -Path Env:/A -Value 1; then verify it with Get-ChildItem Env:/A*. section 5.5

PS C:\Scripts> Get-PSDrive
 
Name           Used (GB)     Free (GB) Provider      Root
----           ---------     --------- --------      ----
/                 159.55        306.11 FileSystem    /
Alias                                  Alias
Env                                    Environment
Function                               Function
Variable                               Variable

The drive listing shows that PSDrives can expose different providers, not only filesystem roots. section 5.1

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

How deep it goes
Explains the provider-to-drive relationship, available drives, item cmdlets, navigation, and cross-platform examples.
Examples
Demonstrates Get-PSDrive, filesystem navigation, New-Item directory creation, and Environment-provider variable management.
What it assumes
Assumes filesystem familiarity while teaching the provider and PSDrive abstractions explicitly.
What you can do after
Operate provider-backed stores through Get-PSDrive, item cmdlets, location changes, and provider-specific paths.
How it connects
Connects PowerShell providers, item cmdlets, Set-Location, filesystem paths, and environment variables.

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.