How to generate a list of hidden items from list or document library list?

Iron Contributor

Hello,

 

How to generate a list of hidden items from list or document library list using PowerShell?

 

Regards

Avian

7 Replies

@Avian 1 What do you mean by "hidden items"? Items which item-level permissions which are not shared with users?

 

If an user account don't have permissions on items, they cannot access list items either from UI or programmatically (PowerShell/REST API, etc.). 

 

You need to login with Site collection administrator (SCA) account and you will see all items in list/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.

Hello Ganeshanap,

Yes, we have the site collection admin access.

If you so many document library and underneath so many folders, it is vert difficult to go each list and library if they are hidden or not.

I am sure using this we can generate the list for all the sites and sub sites.

Regards
Avian

@Avian 1 You can use below PowerShell to get items with unique permissions using PowerShell:

 

SharePoint Online: Get All List Items with Unique Permissions using PowerShell 


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.

Hi @Avian 1

 

Use below PowerShell to get list of hidden lists under a given site

$site = Connect-PnPOnline -Url "YOUR SHAREPOINT SITE URL HERE"
Get-PnPList | Where {$_.Hidden -eq $true}

 

See below implementation on How to to get all site collections with their sub webs

https://pnp.github.io/script-samples/get-all-site-collections-subwebs/README.html?tabs=pnpps

 

Hope this helps!

I tried it, and it shows the lib and where permission are uniqies. I am looking for those items which are hidden.

Hi @Avian 1

 

Can you share your script to know it better?

Another thing - only lists and libraries can be made hidden and not list items. You can apply permissions on list items.  

@Avian 1 

 

Below script should give you all hidden lists / libraries in all sites

$SiteURL = "https://domain-admin.sharepoint.com/"
$UserName = "email address removed for privacy reasons"
$Password = "********"
$SecureStringPwd = $Password | ConvertTo-SecureString -AsPlainText -Force 
$Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecureStringPwd

Function Login {
    [cmdletbinding()]
    param([parameter(Mandatory = $true, ValueFromPipeline = $true)] $Creds)
    Write-Host "Connecting to Tenant Admin Site '$($SiteURL)'" 
    Connect-PnPOnline -Url $SiteURL -Credentials $creds
    Write-Host "Connection Successfull"
}

Function AllSiteCollAndSubWebs() {
    Login($Creds)
    $TenantSites = (Get-PnPTenantSite) | Select Title, Url       
       
    ForEach ( $TenantSite in $TenantSites) { 
        Connect-PnPOnline -Url $TenantSite.Url -Credentials $Creds
        Write-Host $TenantSite.Title $TenantSite.Url
        $subwebs = Get-PnPSubWebs -Recurse | Select Title, Url
        foreach ($subweb in $subwebs) { 
            Connect-PNPonline -Url $subweb.Url -Credentials $Creds
            $hiddenLists = Get-PnPList | Where {$_.Hidden -eq $true}
			foreach ($hiddenList in $hiddenLists) { 
				Write-Host $hiddenList.Title
			}
        }  
    }
}

AllSiteCollAndSubWebs