Advertisement
Xology

Untitled

Mar 20th, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
  2. $allfolderlist = Get-PublicFolder -Recurse | where {$_.name -ne "IPM_SUBTREE"}
  3. foreach ($folder in $allfolderlist) {
  4. $rightslist = Get-PublicFolderClientPermission $folder.Identity | where {$_.user -notlike "svc_quest*" -and $_.user -notlike "exchange services*"}
  5. foreach ($rightentry in $rightslist) {
  6. if (($rightentry.user.UserType) -eq "Default" ) {
  7. write-host "default"
  8. Remove-PublicFolderClientPermission -Identity $folder.Identity -User "Default" -Confirm:$false
  9. Add-PublicFolderClientPermission -Identity $folder.Identity -User "Default" -AccessRight Author
  10.  
  11. } elseif ($rightentry.user.UserType -eq "Anonymous") {
  12. write-host "Anonymous"
  13. Remove-PublicFolderClientPermission -Identity $folder.Identity -User "Anonymous" -Confirm:$false
  14. Add-PublicFolderClientPermission -Identity $folder.Identity -User "Anonymous" -AccessRight None
  15. } else {
  16. write-host "removing: $($rightentry.user)"
  17. Remove-PublicFolderClientPermission -Identity $folder.Identity -User $($rightentry.user) -Confirm:$false
  18. }
  19.  
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement