Forum Discussion
JimBlunt
Sep 07, 2023Brass Contributor
Recursive Script to Get/Set/Remove Exchange Mailbox Folder Permissions
Okay, I have a tiny issue. I'm okay at PS scripting, not a guru by any stretch of the imagination. So here's the situation. Situation: Mailbox needs to move from on-prem to Exchange Online. ...
- Sep 11, 2023
LeonPavesic Over the weekend, I found something that works for me and it's only 6 lines of code. So, in the first 4 lines of code:
- $Alias = Read-Host "Please enter the mailbox alias"
- $Folders = Get-MailboxFolderStatistics -Identity $Alias | Where-Object {$_.FolderType}
- $FolderID = ForEach ($F in $Folders) {$Alias + ":" + $F.FolderID}
- $Perms = ForEach ($F in $FolderID) {Get-MailboxFolderPermission -Identity $F}
Once I take the output from $Perms and condense it down to a usable user list, I can run the last two:
- $Users = Get-Content "C:\Temp\Users.txt"
- ForEach ($F in $FolderID) {ForEach ($U in $Users) {Remove-MailboxFolderPermission $F -User $U -Confirm:$false | Write-Host $F}}
JimBlunt
Sep 08, 2023Brass Contributor
What I really need to know, is how to escape special characters in a folder name, so that it doesn't try and change them. Currently, it's interpreting them as "".