Yes - this is a snippet of code to just display the piece that I am having trouble with. There is no use in me displaying the entire code with bits that are irrelevant to the issue. However, I have to mention it because using a one-line pipe like your post suggests is not an option for me. I have to use a variable and I have to use a for each statement against the array variable. Besides, if there is a performance issue using a variable array and iterating through it with a foreach, I think that’s an issue. I would think you should be able to do that.
To be crystal clear on what I mean by attempting it both ways with the pipe
Method 1 using the $User | method
$mberrors = @()
$global:AllUserMailboxInfo = Get-EXOMailbox -Filter {RecipientTypeDetails -eq 'UserMailBox'} -PropertySets Minimum -ResultSize unlimited
ForEach ($user in $AllUserMailboxInfo)
{
#$user | Get-MailboxPermission -User ******@userdomain.com #takes 50 minutes to complete for 4000 mailboxes
$user | Get-EXOMailboxPermission -User ******@userdomain.com #takes 3 hours to complete for 4000 mailboxes
}
Method 2 using the direct iteration in the foreach loop and using the identity parameter.
$mberrors = @()
$global:AllUserMailboxInfo = Get-EXOMailbox -Filter {RecipientTypeDetails -eq 'UserMailBox'} -PropertySets Minimum -ResultSize unlimited
ForEach ($user in $AllUserMailboxInfo)
{
#Get-MailboxPermission -Identity $user.userprincipalname -User ******@userdomain.com #takes 50 minutes to complete for 4000 mailboxes
Get-EXOMailboxPermission -Identity $user.userprincipalname -User ******@userdomain.com #takes 3 hours to complete for 4000 mailboxes
}
Both of these methods in my testing results in the same performance result.
50 min with the Get-mailboxpermission
3 hrs with the get-exomailboxpermission.
In your example, you are asking me to use a foreach on the Get-EXOMailbox results pipeline instead of using a variable array. I am saying that it is not option on how my entire code works. More importantly, why wouldn't you be able to use a variable array and foreach that array?
Yuki has been able to duplicate this issue with only 50 mailboxes.
Have you been able to test this yourself?