
Effortlessly Manage Office 365 Contacts Using MS Graph PowerShell
Are you spending countless hours managing your Office 365 contacts? Are you tired of scrolling through pages to find specific contacts’ data? Well, no more worries! Microsoft Graph PowerShell is here to save your hours! With its sophisticated functionality module, you can efficiently manage your Office 365 contacts and perform advanced actions on them, while saving time!
Walk with us into this blog and learn about managing external mail contacts using Microsoft Graph.
Manage Office 365 Contacts Using Microsoft Graph
Managing Office 365 contacts can be a time-consuming process, especially for larger organizations with numerous external contacts. However, monitoring Office 365 contacts using Microsoft Graph PowerShell can streamline the process and manage the contacts efficiently.
Therefore, by having a centralized approach to managing contacts, businesses can improve productivity and save time. This allows businesses to focus on what matters most and grow their network without worrying about administrative tasks!
Before getting into the procedure, make sure you Connect to Microsoft Graph PowerShell.
Monitor Office 365 External Contacts Using MS Graph
Regularly reviewing your Office 365 contact details is essential for accuracy and productivity. Periodically auditing your contacts not only enhances communication but also plays a crucial role in security and data protection. By regularly reviewing your contact list, you can identify and remove any unauthorized or suspicious entries, minimizing the risk of unauthorized access to your resources and safeguarding sensitive information.
Overall, monitoring your external contacts is crucial for efficient communication and seamless collaboration with your external colleagues, clients, and partners. Therefore, to help you monitor and review your contact information effectively, Graph PowerShell provides a set of powerful cmdlets.
Get all the Office 365 contacts: To retrieve all the contacts in Office 365 and access their details, you can use the Get-MgContact cmdlet and fetch a comprehensive list of Office 365 contacts along with their relevant information such as email address, display name, job title, etc.
Get-MgContact | Format-Table Mail,Id,DisplayName,JobTitle,Company,MailNickname
View Specific Office 365 Contact– In an Office 365 environment, you may have a vast number of contacts, and scrolling through all the contacts can be tedious and time-consuming, especially when you’re trying to find a specific contact quickly.
Therefore, using the Get-MgContact cmdlet with the OrgContactId parameter enables you to retrieve a specific contact with their related information such as mail, job title, etc. quickly and efficiently. You need to provide the Id of the specific contact in “OrgContactID”parameter.
Get-MgContact –OrgContactId <ContactId>
Monitor External Contact’s Microsoft 365 Group Details Using MS Graph
- Export Microsoft 365 Contacts and Their Associated Groups List
- Get All Groups of a Specific Contact in Office 365
- Check Whether a Contact is a Member of Specific Groups
- List Transitive Membership Groups of Office 365 External Contacts
- Retrieve Office 365 Contacts of a Specific Group
Export Microsoft 365 Contacts and Their Associated Groups List
Analyzing and exporting user contacts along with their associated group memberships provides valuable insights into users’ group relationships. This information enables organizations to make informed decisions on managing contacts by adding or removing them from specific groups based on your organization’s requirements.
Overall, by understanding which groups a contact belongs to, organizations can enhance overall organizational efficiency through effective group management.
$contacts = Get-MgContact $output = foreach ($contact in $contacts) { $groups = Get-MgContactTransitiveMemberOf -OrgContactId $contact.Id foreach ($group in $groups) { $groupId = $group.Id $groupName = (Get-MgGroup -Filter "id eq '$groupId'").DisplayName [pscustomobject]@{ 'Contact Name' = $contact.DisplayName 'Group Name' = $groupName 'Contact ID' = $contact.Id } } } $output | Export-Csv -Path "C:\ContactsAndGroupsInfo.csv" -NoTypeInformation

Get All Groups of a Specific Contact in Office 365
Adding external contacts to Microsoft 365 groups within your organization can significantly enhance collaboration and productivity within your Office 365 environment. But manually verifying each Office 365 group to check for external contacts can be a time-consuming task, especially when dealing with multiple groups. Therefore, use the Get-MgContactMemberOf cmdlet to retrieve all groups of a specific contact in a short time.
$groupId = (Get-MgContactMemberOf -OrgContactId <ContactId>).Id $group = Get-MgGroup -Filter "id eq '$groupId'" $groupName = (Get-MgGroup -Filter "id eq '$groupId'").DisplayName $contact = Get-MgContact -OrgContactId <ContactId> Write-Host "$($contact.DisplayName) belongs to group: $groupName" -ForegroundColor Green
Check Whether a Contact is Member of Specific Groups
The Confirm-MgContactMemberGroup graph cmdlet can be used to confirm whether a contact is a member of a group.. This cmdlet allows you to check the group membership status of a particular contact.
By executing the PowerShell script below, you can easily determine whether the contact is a member of the specified group or not. This functionality is useful for managing and organizing contacts within groups, enabling you to perform actions or apply settings based on their membership status.
$ContactId = (Get-MgContact -Filter "displayName eq '<Contact’s Display Name>'").id $GroupIds = @("<Group ID 1>", "<Group ID 2>") foreach($GroupId in $GroupIds){ $IsMember = Confirm-MgContactMemberGroup -GroupIds $GroupId -OrgContactId $ContactId if($IsMember){ $Group = Get-MgGroup -Filter "id eq '$GroupId'" Write-Host "Contact $($Contact.displayName) is a member of group $($Group.displayName)" -ForegroundColor Green } else { $Group = Get-MgGroup -Filter "id eq '$GroupId'" Write-Host "Contact $($Contact.displayName) is not a member of group $($Group.displayName)" -ForegroundColor Green } }

List Transitive Membership Groups of Office 365 External Contacts
Tracking the report of a user’s transitive membership groups is essential to gain a clear understanding of group relationships, access privileges, potential security vulnerabilities, and the complex network of group relationships within an organization.
You can get a list of groups the contact has transitive and direct membership by running the below cmdlet.
$contactName = (Get-MgContact -Filter "id eq '$orgContactId'").DisplayName $groupNames = (Get-MgContactTransitiveMemberOf -OrgContactId "<ContactId>").Id | ForEach-Object { (Get-MgGroup -Filter "id eq '$_'").DisplayName } $groupMemberships = $groupNames | ForEach-Object { "$contactName belongs to group $_" } | ForEach-Object { Write-Host $_ -ForegroundColor Green }
Retrieve Office 365 Contacts of a Specific Group
Sometimes, admins might have to send invitations to external contacts to access your organization’s resources. At times, rather than sending it to each contact individually, it can be more efficient to share the invitation with the entire group that your external contacts are a part of. Therefore, to find out whether the required contacts are present within a specific group, you can use the below script and retrieve all the contacts for a particular group.
In short, this approach streamlines the process of ensuring the right individuals receive the necessary access, simplifying communication and resource sharing.
$groupId = "<Group Id>" $members = Get-MgGroupMember -GroupId $groupId $contacts = foreach ($member in $members) { Get-MgContact -Filter "id eq '$($member.Id)'" | Select-Object DisplayName, Mail, JobTitle } $contacts | Export-Csv -Path "<C:\ ContactsInaGroup.csv>" -NoTypeInformation

Modify Office 365 External Contacts Using Graph PowerShell
Update Display Name of an Office 365 Contact – To modify the display name of an Office 365 contact using Microsoft Graph PowerShell, you can utilize the provided cmdlet. For a comprehensive list of editable attributes, you can check the MS document.
Update-MgContact -DisplayName <NewDisplayName> -OrgContactId <ContactId>
Remove Office 365 Mail Contacts – If you suspect that an external contact is engaging in malicious activities inside your organization, it’s crucial to take action to prevent any potential data breaches. One way to mitigate the risk is by removing the contact from your organization’s contact list.
Therefore, to remove a contact, you can use the following PowerShell cmdlet:
Remove-MgContact –OrgContactId <ContactId>
This cmdlet will delete the specific contact, and afterwards we can verify that the contact has been successfully removed from the contact list by running the ‘Get-MgUser’ cmdlet to check that the deleted contact is no longer present in the list.
Give a Try to Manage Your Office 365 Contacts With MS Graph!
In conclusion, managing contacts in your Microsoft 365 environment can be a tedious task. But with the help of Microsoft Graph PowerShell, you can effectively manage your external contacts in Office 365 and ensure that your contact list is accurate and up to date. So, don’t let contact management hold up your time! By the way, don’t end up yourself with this module alone! Perform advanced actions such as bulk import of office 365 contacts, hiding Office 365 contacts, hiding users and groups from GAL using Exchange Online module now!
Try the methods discussed above and streamline your Microsoft 365 contact management today! Furthermore, feel free to reach us in the comments section for any assistance.