PSDrives and PSProviders

In PowerShell, there are different PSProviders available. But what is a PowerShell provider, exactly? It is a representation of a data storage location, where you are able to use basic commands regarding specific data types. For example, FileSystem is the PSProvider, when working in the context of the filesystem. As you can see in the following table, this is available in the standard PSDrive. In this context, you work directly with the built-in cmdlets directed to this data store. A good example is Get-ChildItem, which retrieves the child items of the current location in the current PSDrive. When working in the filesystem, the types are files and directories, but in the certificate PSDrive, they will be the available certificates. The following table shows all of the available PSDrives with their corresponding PSProvider, which are available by default:

PSProvider
PSDrive
Data Store

Alias

Alias:

PowerShell aliases

Certificate

Cert:

x509 certificates for digital signatures

Environment

Env:

Environment variables

FileSystem

(*)

Filesystem drives, directories, and files

Function

Function:

PowerShell functions

Registry

HKLM:, HKCU:

Windows registry

Variable

Variable:

PowerShell variables

WSMan

WSMan:

WS-Management configuration information for remoting

You can retrieve a complete list of available PSProviders with the Get-PSProvider cmdlet. Later on in this book, we will provide some examples regarding PSDrives, and we will introduce a new one called Azure:. The good thing about this is that you can just work with the well-known cmdlets and use them in all of the different PSDrives. It's as easy as that.

Take a look by yourself and retrieve the PSDrives that are currently available by using Get-PSDrive. You will see a table like the following:

Used

Free

Name

Provider

Root

Description

Alias

Alias

 

Drive that contains a view of the aliases stored in a session state

##

##

C

FileSystem

C:

Cert

Certificate

X509 Certificate Provider

##

##

D

FileSystem

D:

External_SSD

E

FileSystem

E:

Env

Environment

 

Drive that contains a view of the environment variables for the process

Function

Function

 

Drive that contains a view of the functions stored in a session state

HKCU

Registry

HKEY_CURRENT_USER

The software settings for the current user

HKLM

Registry

HKEY_LOCAL_MACHINE

The configuration settings for the local computer

Variable

Variable

 

Drive that contains a view of those variables stored in a session state

WSMan

WSMan

 

Root of WSMan config storage

 

This standardization will help you a lot. With each of these PSDrives, you will have the following cmdlets available. Therefore, you should get familiar with them, as you will need them more frequently:

  • ChildItem cmdlets:
    • Get-ChildItem
  • Content cmdlets:
    • Add-Content
    • Clear-Content
    • Get-Content
    • Set-Content
  • Item cmdlets:
    • Clear-Item
    • Copy-Item
    • Get-Item
    • Invoke-Item
    • Move-Item
    • New-Item
    • Remove-Item
    • Rename-Item
    • Set-Item
  • ItemProperty cmdlets:
    • Clear-ItemProperty
    • Copy-ItemProperty
    • Get-ItemProperty
    • Move-ItemProperty
    • New-ItemProperty
    • Remove-ItemProperty
    • Rename-ItemProperty
    • Set-ItemProperty
  • Location cmdlets:
    • Get-Location
    • Pop-Location
    • Push-Location
    • Set-Location
  • Path cmdlets:
    • Join-Path
    • Convert-Path
    • Split-Path
    • Resolve-Path
    • Test-Path
  • PSDrive cmdlets:
    • Get-PSDrive
    • New-PSDrive
    • Remove-PSDrive
  • PSProvider cmdlets:
    • Get-PSProvider

We will use some of them in examples in the book, so you will also see some use cases in detail. For now, we will stop here, and you can use these lists as a glossary if you need to search for or remember any cmdlets.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.252.201