I have a script who's purpose is to go through all the mailboxes in exchange and look for any with SG_ or Group listed in the Full Access Permissions. The script works though I'm having trouble formatting the data in a way that I can use it in Excel.
Ultimately I'd like it to report the Name of the mailbox and the name of the entry listed in the Full Access Permissions that has SG_ or Group in the name. Currently the output is the name of the mailbox and then on a separate line the full name of the security group.
I'm trying to have it so that each part is in it's own column. That will make it easy to review in excel.
$Grabmailbox = Get-Mailbox -Resultsize Unlimited
foreach ($mailbox in $Grabmailbox){
$Getpermission = Get-MailboxPermission $mailbox | where { ($_.User -like "corp\SG_*") -or ($_.User -like "corp\*_group") }
if ($Getpermission -ne $null) {
echo "$mailbox + "$Getpermission | FT User |Out-File c:\Script\VerifiedSG.txt -Append
}
else{
echo "$mailbox + No SG detected" | Out-File c:\Script\VerifiedSG.txt -Append
}
}