Good Morning Everyone,
I’m currently trying to run a little script to find all the users that still have access rights set on them from a migration. I opted to use the new EXO commands in the hope that it would be quicker, but I feel like I did something wrong. Here is the script that I’m running below. Where am I going wrong? Is is the where pipe to clean up the users or the Out-string?
$Mailboxes = Get-EXOMailbox -ResultSize Unlimited $Mailboxes.count $i = 0 $A = @() foreach ($Mailbox in $Mailboxes){ $B = Get-EXOMailboxPermission -Identity $Mailbox.UserPrincipalName | ? User -like *@* $item = New-Object psobject $item | Add-Member -type NoteProperty -Name 'Mailbox' -Value $Mailbox.DisplayName $item | Add-Member -type NoteProperty -Name 'UPN' -Value $Mailbox.UserPrincipalName $item | Add-Member -type NoteProperty -Name 'Accessing User' -Value $B.User $item | Add-Member -type NoteProperty -Name 'Access Rights' -Value ($B.AccessRights | Out-String).Trim() $A += $item $i++ Write-Progress -activity "Looking up user access" -status "Lookedup: $i of $($Mailboxes.Count)" -percentComplete (($i / $Mailboxes.Count) * 100) }