Sep 25 2022 03:26 AM
Hello,
How to generate a list of hidden items from list or document library list using PowerShell?
Regards
Avian
Sep 25 2022 10:14 PM
@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.
Sep 26 2022 01:55 AM
Sep 26 2022 02:16 AM
@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.
Sep 26 2022 03:50 AM
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!
Sep 26 2022 04:14 AM
Sep 26 2022 04:16 AM
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.
Sep 26 2022 04:20 AM
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