PnP PowerShell and more...

Here I occasionally post about Microsoft 365 Patterns and Practices in general and PnP PowerShell more specifically.

The hidden gem in PnP PowerShell

2018-03-17 1 min read

There is something ‘hidden in plain sight’ in PnP PowerShell for SharePoint Online, and it’s been there already for a few years. Let me show you the command:

Connect-PnPOnline -Url https://contoso.sharepoint.com -CreateDrive

Notice that last parameter? -CreateDrive. It does exactly what it says it does. It creates a drive that you can navigate into. And you are effectively navigating into your site. How cool is that?

By default it creates a drive called SPO:

Connect-PnPOnline -Url https://contoso.sharepoint.com -CreateDrive
cd SPO:\
cd SitePages
dir


   Folder: \SitePages

Name         Type   Items/Size Last Modified
----         ----   ---------- -------------
Forms        Folder          0 2017-02-13 19:50:58
DevHome.aspx File         3356 2017-03-07 09:55:45

and you will see the contents of your site. And you can copy things around, delete things, etc.

If you want to call the drive something different, simply use the -DriveName yourname parameter.

Notice that the drive only works in PowerShell. E.g. you cannot navigate to it by using the File Explorer or the Finder on a Mac (Mac? Yes. See more here: https://www.erwinmcm.com/cross-platform-pnp-powershell/).