obtener_miembros_de_cada_buzon_compartido_de_exchange

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
obtener_miembros_de_cada_buzon_compartido_de_exchange [2023/05/17 15:51] – created osoobtener_miembros_de_cada_buzon_compartido_de_exchange [2024/10/17 21:42] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +===== Q: I need to get the members of a list of Exchange groups (distribution groups and shared inboxes). =====
 +
 +
 You can use PowerShell and the Microsoft 365 Exchange Online PowerShell module to retrieve the members of Exchange groups in your Microsoft 365 tenant. Here's an example script that reads a list of group names from a text file and exports the group members to a CSV file: You can use PowerShell and the Microsoft 365 Exchange Online PowerShell module to retrieve the members of Exchange groups in your Microsoft 365 tenant. Here's an example script that reads a list of group names from a text file and exports the group members to a CSV file:
  
Line 35: Line 38:
 Please note that you'll need to have the necessary administrative rights and permissions to execute these commands in your Microsoft 365 tenant. Please note that you'll need to have the necessary administrative rights and permissions to execute these commands in your Microsoft 365 tenant.
  
-===== Obtener el tipo de cuenta =====+===== Obtener el tipo de cuenta (Q: How can I get the type of mailbox with powershell? Some addresses are shared mailboxes, others are distribution groups. I would like a list containing the type of group/mailbox of my list of email addresses. =====
  
  
Line 86: Line 89:
 The script connects to Exchange Online, reads the email addresses from the text file, and then iterates through each email address. It checks if the address belongs to a mailbox using the `Get-Mailbox` cmdlet and if it belongs to a distribution group using the `Get-DistributionGroup` cmd The script connects to Exchange Online, reads the email addresses from the text file, and then iterates through each email address. It checks if the address belongs to a mailbox using the `Get-Mailbox` cmdlet and if it belongs to a distribution group using the `Get-DistributionGroup` cmd
  
-===== Exportar buzones compartidos =====+===== Exportar buzones compartidos (Q: By following the script you proposed, about reading a list of group names from a text file and exporting the group members to a CSV file, I need the same script but for exporting the membership of Shared Mailboxes, not distribution groups) =====
  
  
Line 135: Line 138:
 Please give this updated script a try, and it should provide you with the membership details of the Shared Mailboxes listed in the text file. Please give this updated script a try, and it should provide you with the membership details of the Shared Mailboxes listed in the text file.
  
-==== En vez de User es Trustee ====+==== Q: The only correction I had to do: instead of "Select-Object User" I used "Select-Object Trustee====
  
  
Line 141: Line 144:
  
 I'm glad to hear that the rest of the script worked flawlessly for you. If you have any more questions or need further assistance, feel free to ask. I'm glad to hear that the rest of the script worked flawlessly for you. If you have any more questions or need further assistance, feel free to ask.
 +
 +==== Q: What is the purpose of "Where-Object { $_.AccessRights -contains "FullAccess" -and $_.IsInherited -eq $false }"? why are you proposing that filtering? ====
 +
  
 The purpose of the `Where-Object` filtering in the script is to retrieve only the mailbox permissions entries that meet specific criteria. Let's break down the filtering criteria used: The purpose of the `Where-Object` filtering in the script is to retrieve only the mailbox permissions entries that meet specific criteria. Let's break down the filtering criteria used:
  
-1. `$_` represents the current pipeline object, which in this case is each mailbox permission entry. +  - 1. `$_` represents the current pipeline object, which in this case is each mailbox permission entry. 
-2. `AccessRights -contains "FullAccess"` checks if the mailbox permission includes the "FullAccess" access right. This ensures that only permissions with FullAccess are selected. +  2. `AccessRights -contains "FullAccess"` checks if the mailbox permission includes the "FullAccess" access right. This ensures that only permissions with FullAccess are selected. 
-3. `IsInherited -eq $false` checks if the permission is not inherited from a parent object. This excludes any permissions inherited from higher-level groups or objects, and only includes direct permissions set on the mailbox.+  3. `IsInherited -eq $false` checks if the permission is not inherited from a parent object. This excludes any permissions inherited from higher-level groups or objects, and only includes direct permissions set on the mailbox.
  
 By combining these criteria, the script filters out any mailbox permissions that are not directly assigned and do not have FullAccess. This helps to ensure that only relevant mailbox permissions are included in the final result. By combining these criteria, the script filters out any mailbox permissions that are not directly assigned and do not have FullAccess. This helps to ensure that only relevant mailbox permissions are included in the final result.
Line 152: Line 158:
 If you have specific requirements for filtering the mailbox permissions, you can adjust or remove this filtering as per your needs. If you have specific requirements for filtering the mailbox permissions, you can adjust or remove this filtering as per your needs.
  
-===== Versión 2 =====+===== Q: Look, it would be great if the output file stores the pair of addresses: "SharedMailbox, Trustee" so I can filter by Shared Mailbox in my spreadsheet. That and please forget about the "full AccessRights" and "IsInherited -eq $false" filter =====
  
 Certainly! Here's the modified script that includes the pair of addresses "SharedMailbox, Trustee" in the output CSV file: Certainly! Here's the modified script that includes the pair of addresses "SharedMailbox, Trustee" in the output CSV file:
Line 201: Line 207:
  
 $result | Export-Csv -Path "C:\Users\Facundo\OneDrive - TandemStudio Cloud\APR\output_2.csv" -NoTypeInformation $result | Export-Csv -Path "C:\Users\Facundo\OneDrive - TandemStudio Cloud\APR\output_2.csv" -NoTypeInformation
 +</code>
 +
 +====== Obtener listas de SharedMailboxes y Listas de distribución en un .csv cada una ======
 +
 +
 +<code powershell: getMailboxes.ps1>Connect-ExchangeOnline
 +
 +$mailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox
 +
 +$result = foreach ($mailbox in $mailboxes) {
 +    $permissions = Get-MailboxPermission -Identity $mailbox.Identity
 +
 +    foreach ($permission in $permissions) {
 +        [PSCustomObject]@{
 +            SharedMailbox = $mailbox.PrimarySmtpAddress
 +            Trustee = $permission.User
 +        }
 +    }
 +}
 +
 +$result | Export-Csv -Path "C:\tmp\exchangeOnline_SharedMailboxes_Output.csv" -NoTypeInformation
 +
 +$distributionLists = Get-DistributionGroup
 +
 +$result = foreach ($distributionList in $distributionLists) {
 +    $groupMembers = Get-DistributionGroupMember -Identity $distributionList.Identity
 +
 +    foreach ($member in $groupMembers) {
 +        [PSCustomObject]@{
 +            DistributionList = $distributionList.PrimarySmtpAddress
 +            Member = $member.Name
 +        }
 +    }
 +}
 +
 +$result | Export-Csv -Path "C:\tmp\exchangeOnline_DistribGroups_Output.csv" -NoTypeInformation
 </code> </code>
obtener_miembros_de_cada_buzon_compartido_de_exchange.1684338687.txt.gz · Last modified: 2024/10/17 21:42 (external edit)