Custom PSDrive can be created by using New‑PSDrive PowerShell command.
Custom PSDrives can be created in different providers.
Just as you can create a PSDrive in file system providers,
you can also create PSDrives in registry providers,
as well as certificate providers.
So, if you create a new PSDrive in file system provider,
you will be able to manage files and folders under that PSDrive.
You may create a PSDrive mapped to a registry path to manage registry values,
and you may create a PSDrive mapped to a
certificate store to manage certificates.
Custom PSDrives act as a shortcut to navigate to a path in datastore,
like file system and registry.
These drives can be temporary or persistent in nature.
By default,
the PSDrive that you create will be temporary and will exist
only in the session in which it is created.
You can give any name to this drive that is valid in PowerShell.
Temporary drives can be created for a local resource
or a resource on a remote server.
Now, when I say a resource, it can be a folder path,
a registry path,
or a certificate store path on local server or on a remote server.
Since temporary drives are session specific,
they cannot be managed using other methods like Net Use command.
However, within the same session,
you can carry out some common operations in the temporary PSDrive,
like changing the location within the drive using set‑location command,
managing child objects using commands such as get‑item and get‑child‑item.
Persistent PSDrive, on the other hand, will be available to use in the same,
as well as in other PowerShell sessions.
If you want to create a persistent PSDrive,
you will need to include persist parameter in the new PSDrive command.
Persistent drives work in the same fashion as temporary drives.
The only difference here is that persistent drives can be created only
for a file system location on a remote computer,
and it should be mapped only by a drive letter between A to Z.
You cannot simply map a local folder in a persistent drive. Persistent
drives can also be viewed using Net Use command. Even though persistent
drives are retained in other PowerShell sessions,
they disappear after a system reboot.
So, if you have a requirement where you have to
consistently keep a custom PSDrive intact,
even after a reboot,
you can have a login script set for your account or have
that drive set in your PowerShell profile.
Later in the demo,
we will set a PowerShell profile to include a persistent drive, so
that whenever we start a new PowerShell session, this drive will be available to us.