Level 1
0 / 100 XP

Using PS Drive

In this lecture we will learn how to use PSDrive. The PSDrive cmdlet allows you to view, create and remove PowerShell drives. A PSDrive is considered a data store location that can represent the file system, a registry hive and network share, among other things as well.

If you want to follow along, download the lesson that came with this lecture. You'll find all the commands that we're going to use in the lesson.

  • Go ahead and open PowerShell as the current user. We will use the cmdlet New-PSDrive to create a temporary or persistent drive that is mapped to or associated with a location in a data store.

To see the syntax of PSDrive type Get-Help New-PSdrive , press return.

  • We will be using the command New-PS Drive and the parameters Name, PSProvider and Root.
  • In our example, daily on a machine, you need to check a particular registry key. You have to open the registry editor, and drill down to that specific registry hive. In this case HKLM, and find the registry key.

I'm going to show you how to use New-PS drive to map that registry location to a name. And make it assessable like any file system drive.

  • Now go ahead and copy and paste the first command into PowerShell.

Command #1

New-PSDrive -Name PSReg -PSProvider Registry -Root HKLM:\SOFTWARE\Microsoft\PowerShell\3\

Now what are the following parameters used for? -Name specifies a name for the new drive -PSProvider this shows that the drive is associated with the registry. -Root specifies the data store location to which a PowerShell drive is mapped. And HKLM is the target registry hive. Now press **return. **

To access the newly created PSDrive Type cd space psreg: don't forget the colon just after the psreg: name, otherwise you will get an error. And press return.

Now type dir , and press return. And there is our registry entries.

  • Additional PSDrive…