Effortlessly Manage Office 365 Contacts Using MS Graph PowerShell

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

  1. Export Microsoft 365 Contacts and Their Associated Groups List
  2. Get All Groups of a Specific Contact in Office 365
  3. Check Whether a Contact is a Member of Specific Groups
  4. List Transitive Membership Groups of Office 365 External Contacts
  5. 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 a list of contacts and their associated groups

Note: Microsoft 365 contacts and Microsoft Outlook contacts are different from each other. To export Outlook contacts into CSV, there is an option “Export Contacts” in Outlook interfaces.

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 
    }    
} 

Check whether a user belong to a group or not using MS Graph

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

Get all contacts of a specific group using MS graph

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.

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!

Gain Control Over Your Office 365 Contacts with AdminDroid

😥Long scripts! Are you tired of looping through cmdlets and writing long scripts to gather more information about your Office 365 contacts? Surfing the web for a better alternative to manage Office 365 contacts without any cmdlets?

We got you! Introducing AdminDroid, the all-in-one Microsoft 365 report hub that offers powerful reporting and auditing capabilities, assisting admins to efficiently manage their Office 365 contacts. With AdminDroid, you can easily generate Microsoft 365 users reports, such as user’s group memberships, Microsoft 365 external users, sign-in disabled users, unlicensed users etc. for seamless Office 365 management.

AdminDroid Azure AD reporting tool consolidates information about your organization’s contacts into a single report, making it easier for you to manage your Office 365 contacts efficiently. With just a few clicks, you can gain comprehensive insights into contacts’ sign-in status and groups with contacts as members right at your fingertips. Below are a few Office 365 contacts-related reports by AdminDroid.

Office 365 Contacts Reports

  • All Contacts– List of all contacts in your Office 365 environment.
  • Groups with Contacts as Members– Displays all the Microsoft 365 groups with your contacts as members.
  • Mail Contact Changes– Summary of all the changes made at Office 365 Contacts.

Manage Contact changes with AdminDroid

Contacts membership details with AdminDroid

Not only can you granularly filter the reports with advanced filtering capabilities, but you can also take your contact management to the next level! With AdminDroid’s robust filtering options, you can retrieve group names based on specific users, effortlessly locate groups that include contacts from particular companies, and so much more. Moreover, AdminDroid is designed to streamline your Azure AD management experience, making to more efficient and effective.

Furthermore, AdminDroid being the best tool for Azure AD and Exchange Online management, it provides better control over license consumption, privilege assignments, mailbox management, mailbox permissions, mailbox protocols from a central console.

No cost! No Expiry! No limitations in functionalities! Yeah, AdminDroid offers Azure AD reports for your Office 365 environment for absolute Free, making effortless Azure AD management.

Don’t waste your time! Check out the 15 days free trial of AdminDroid and manage Azure AD and Exchange Online effectively.

We hope this blog have given you more information for effective Office 365 contacts management. Furthermore, feel free to reach us in the comments section for any assistance.

Effortlessly Manage Office 365 Contacts Using MS Graph PowerShell

by Sudha time to read: 7 min
0