SOLVED

PowerShell PnP "Shared Documents"

Brass Contributor

Hi

 

The answer to this is probably staring me in the face, and will be trivial to many on this forum I suspect.  I want to create a list using PnP PowerShell, with items based on document libraries and folders in the site.  I have this working, apart from the issue where the Documents document library needs to be "Shared Documents" when I use Get-PnPFolderItem -FolderSiteRelativeUrl.  I don't see a property in the PnpList objects that I can use for this.  I looked at EntityTypeName but it needs to be parsed, or I could grab part of one of the URL properties I guess, but I was looking for a more elegant solution.

 

TIA

4 Replies

@stromnessian Are you trying to get the name of document library ("Shared Documents") in library URL dynamically? 

Try using Get-PnPList command if it helps you.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

To clarify:
Step 1. is to find all document libraries using Get-PnpList.
Step 2. is to, for each of the above, find all top level folders using Get-PnPFolderItem -FolderSiteRelativeUrl.

I initially used the Title property of the lists found in 1., but this doesn't work for "Shared Documents" as the title is "Documents".
best response confirmed by stromnessian (Brass Contributor)
Solution

@stromnessian You can use this PowerShell: 

 

$lists = Get-PnPList -Includes RootFolder
$lists.RootFolder.Name

 

This will give you the correct name of document library. 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Awesome, thanks @ganeshsanap!

1 best response

Accepted Solutions
best response confirmed by stromnessian (Brass Contributor)
Solution

@stromnessian You can use this PowerShell: 

 

$lists = Get-PnPList -Includes RootFolder
$lists.RootFolder.Name

 

This will give you the correct name of document library. 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

View solution in original post