Microsoft Exchange
2 TopicsRecursive 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. I know how to do this...easy peasy. Mailbox move request errors out because of invalid permissions on some of the folders. Mailbox contains 12,053 folders. I have a one line command that will go and get all of the folder names and spit them out on the screen. It works just fine. $folders = Get-Mailbox <Alias> | ForEach-object {Get-MailboxFolderStatistics -Identity $_.alias | Select-Object Identity, ItemsInFolder, DeletePolicy, FolderSize}; $folders | Out-GridView I expanded upon that and went out to the Internet and found one that will recursively get the folder list and the permissions for each folder: $Perms = ForEach ($f in (Get-MailboxFolderStatistics <Alias> | Where {$_.FolderPath.Contains("/") -eq $True } ) ) {$fname = "<Alias>:" + $f.FolderPath.Replace("/", "\"); Get-MailboxFolderPermission $fname}; $Perms | Out-GridView Problem: For most mailboxes, this command works fine. However, this mailbox is determined to make me have a mental breakdown. In the folder names, they have used forward slash "/", open and close braces "[", "]", colons ":", hyphens "-", At signs "@", open and close parenthesis "(", ")", and ampersands "&". If I manually enter all those characters into the Get-MailboxFolderPermission command for the folder name, with quotes around the entire thing, it doesn't have any issue. For example: Get-MailboxFolderPermission -Identity "<Alias>:\2023 Meetings/Trips/Events\02 February\[02/05 2:00-3:00 pm Telecon w/XYZ & Joe Smith]" If I run: Get-MailboxFolderPermission and that long, screwed up path, it works fine. If I run: Get-MailboxFolderStatistics with that same Identity value, I get: Unable to retrieve mailbox folder statistics for mailbox <Alias>:\2023 Meetings/Trips/Events\02 February\[02/05 2:00-3:00 pm Telecon w/XYZ & Joe Smith]. Failure: Couldn't find '<Alias>:\2023 Meetings/Trips/Events\02 February\[02/05 2:00-3:00 pm Telecon w/XYZ & Joe Smith]' as a recipient. If I run: Get-MailboxFolder with the same Identity value, I get: The specified mailbox "<Alias>" doesn't exist. If I run the script as originally written in the bottom bullet of the Problem, I get an error like this: The operation couldn't be performed because '<Alias>:\2023 Meetings/Trips/Events\02 February\[02/05 2:00-3:00 pm Telecon w/XYZ & Joe Smith]' couldn't be found. + CategoryInfo : NotSpecified: (:) [Get-MailboxFolderPermission], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=ServerName,RequestId=47c592c0-dbc1-4ca5-b873-1dc5825aa23a,TimeStamp=9/7/2023 4:12:03 PM] [FailureCategory=Cmdlet-Manag ementObjectNotFoundException] CDF486FF,Microsoft.Exchange.Management.StoreTasks.GetMailboxFolderPermission + PSComputerName : ServerName.domain.com What can I do? How can I rewrite that script in order to parse that folder name correctly? Thanks in advance, JimSolved5KViews0likes3Commentsconnecting to exchange 2010 server
A long time i connected to exchange on premise 2010 server from a client. The command to connect (run powershell as admin or special user which has rights to exchange remote): $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http:///PowerShell/ -Authentication Kerberos -Credential $UserCredential In stead of "powershell" i fill in the fqdn of the exchange server. This always worked but not anymore. I do not know what changed locally or on the exchange server but this is the error: New-PSSession : [servername.fqdn] Connecting to remote server fqdn failed with the following e rror message : Cannot connect to the destination that is given on request. Check that the service is running on the destination and accepts requests. Read the log for wsman, check the management service which is stared on the destination (usually WINRM or IIS, if it is winrm start winrm quickconfig. see the about_Remote_Troubleshooting Help topic. At line:1 char:12 + $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin gTransportException + FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed the exchange 2010 server is accepting requests, winrm quickconfig says this and is running. I have downloaded and started emtshooter to see what the problem could be: emtshooter says that the account that is running does not have exchange remote access. To check this run the following command on exchange: (get-user domain\user).remotepowershellenabled for all the users which i use in Powershell it says enabled (this is very strange) i have tried users with domain without domain and fqdn but they all have remotepowershell enabled. What can this be, if it is not the Exchange fw?3.4KViews0likes12Comments