Maybe you wan to try this.
# Get all public folders
$publicFolders = Get-PublicFolder -Recurse
# Create an empty array to hold the results
$results = @()
# Iterate over each public folder
foreach ($folder in $publicFolders) {
# Check the item count
$stats = Get-PublicFolderItemStatistics $folder.Identity
if ($stats.Count -eq 0) {
# If the item count is zero, get the permissions
$permissions = Get-PublicFolderClientPermission $folder.Identity
foreach ($permission in $permissions) {
# For each permission, create a custom object with the details we want
$result = New-Object PSObject -Property @{
"FolderName" = $folder.Identity
"User" = $permission.User
"AccessRights" = $permission.AccessRights
}
# Add the result to our results array
$results += $result
}
}
}
# Export the results to a CSV file
$results | Export-Csv -Path "EmptyPublicFolders.csv" -NoTypeInformation
This script will create a CSV file called EmptyPublicFolders.csv
with columns for FolderName
, User
, and AccessRights
. Each row will represent a permission for a user on a public folder with zero items. You can then use this CSV to contact the users.