to get the hidden folder in sharepoint using powershell pnp

73 views Asked by At

I want to change the owner of a folder C2574AA000FC365CC25767A000F9AFE which is hidden, I can see this from browser , but can not fetch this using powershell cmdlet.

$Folder = Get-PnPFolder -Url $RelativePath_Folder Get-PnPFolder : File Not Found.

1

There are 1 answers

0
Emily Du - MSFT On

Please try below PnP PowerShell.

#Config Variables
$SiteURL = "https://wendytest123.sharepoint.com/sites/emilytestnew"
$ParentFolderURL= "/Shared Documents" #Parent Folder's Site Relative Path
$FolderName="foldername"
$UserAccount = "[email protected]"
 
#Get Credentials to connect
$Cred = Get-Credential
  
Try {
    #Connect to SharePoint Online site
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred
  
    #Get the Folder
    $Folder = Get-PnPFolderItem -FolderSiteRelativeUrl $ParentFolderURL -ItemName $FolderName
    Set-PnPListItemPermission -List $ListName -Identity $Folder.ListItemAllFields -User $UserAccount -AddRole 'Full control'
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}