Petri Newsletter Sign-up
Office 365 Insider

Here at, we get IT — and so can you. Subscribe today to stay informed and knowledgeable regarding the latest on IT.

    See All Petri Newsletters

    Getting Started with vSphere PowerCLI: PSDrives

    Posted on by Jeff Hicks in VMware with 3 Comments

    We’re back with our multi-part series on VMware’s vSphere PowerCLI, a free snapin you can use to manage your VMware infrastructure. Today we’ll go over PowerCLI and PSDrives. But if you need to back up: In part one, we took a look at downloading and installing PowerCLI. In part two, we went through the steps of setting up and configuring PowerCLI. Later, in part five I’ll create a new VM. And finally, in part six I show you how to use PowerCLI to manage your ISO files.)

    The PSDrives that you get with PowerCLI are perhaps the most compelling feature. You can use the same file system commands to manage and manipulate the files related to your VMware infrastructure. I hope you are beginning to see, if you haven’t already, that PowerShell is becoming the only management tool you need to learn.

    Installing PowerCLI: Providers

    When you install PowerCLI, one of the new goodies you get is a provider. Actually, you get two providers.

    These providers are what make all of the PowerCLI magic possible. You can read more about the VimDatastore provider.

    Sadly, there is no corresponding help topic on the VimInventory provider. Nevertheless, what this means for you is that you can navigate your VMware infrastructure as if it were a file system.

    vSphere PowerCLI PSDrives

    When you first add the snapin, PowerShell will automatically add several PSDrives.

    However, they aren’t really connected to anything until you connect to a server.

    The inventory drive gives you access to different infrastructure elements, as shown below in Figure 1.

    vSphere PowerCLI PSDrives: inventory

    The vmstore: PSDrive lets you browse your infrastructure from the virtual machine side, as you can see in Figure 2.

    vSphere PowerCLI PSDrives

    What this means to you is that you can navigate all of the files associated with a virtual machine like a file system.

    vSphere PowerCLI PSDrives

    If I wanted to, I could copy, move or delete files. Or perhaps I’d like to know how much space each virtual machine is consuming.

    The image below displays my results.

    vSphere PowerCLI PSDrives

    The virtual machines seen here may nor not be added to the inventory you would see in the vSphere client.

    One thing to remember is that names in these PSdrives are case-sensitive. If I try a command like this it will fail with an error about an invalid path.

    Your best bet is to take advantage of tab completion to discover the proper case. But once I know that I can easily delete obsolete files from the server.

    One thing you can’t do is copy or move files between the file system and the VMware server. These types of operations only work within the same provider. At least using the native PowerShell commands. Fortunately, PowerCLI includes some cmdlets that will cross providers. The benefit is that you can copy items between the file system and the VMware PSDrive.

    This one line command copied an ISO file from my computer to the ISO folder in datastore3 on my VMware server.

    While the PSDrives are fun to work with, I encourage you to use cmdlets wherever possible, especially those that ship with PowerCLI.


    Don't have a login but want to join the conversation? Sign up for a Petri Account