Phone numbers from all users' contact information on outlook.

IniobongNkanga-8038 631 Reputation points
2024-08-29T09:18:11.81+00:00

Hello

Please i need your help on this issue

I would like to use PowerShell to remove phone numbers from all users' contact information on outlook.

Also to use PowerShell to add phone numbers for multiple users in Microsoft Entra.

Microsoft Exchange Online
Outlook
Outlook
A family of Microsoft email and calendar products.
3,818 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,228 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,509 questions
Microsoft Entra
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 46,711 Reputation points
    2024-08-29T15:44:45.6333333+00:00

    Are the contacts Outlook contacts, or MS Exchange contacts (i.e., in the Active Directory)?

    If they're in the AD you'd use Get-Contact and Set-Contact cmdlets, or Get-MailContact and Set-MailContact cmdlets.

    If they're contacts created by mailbox owners you'll probably have to resort to using Invoke-RestMethod if the mailboxes are in Exchange Online (Example: https://gsexdev.blogspot.com/2014/04/oneliner-mailbox-access-in-powershell.html). If your Exchange is on-prem you'll some pointers here: https://www.undocumented-features.com/2019/07/16/some-of-the-many-ways-to-export-outlook-contacts/

    Using Entra, you'll probably have to use the PowerShell Microsoft.Graph.Entra module.

    0 comments No comments

  2. Alex Zhang-MSFT 865 Reputation points Microsoft Vendor
    2024-08-30T08:23:57.2533333+00:00

    Hello, @IniobongNkanga-8038,

    Welcome to the Microsoft Q&A platform!

    Based on your description, I understand that you want to learn how to use PowerShell to remove phone numbers from the contact information of all users on Outlook and add phone numbers for multiple users in Microsoft Entra.

    After testing, you can realize deleting the phone numbers of all contacts at once with the following command in PowerShell.

    1.Use the following command in PowerShell to get the current mailbox contact name and phone number.

    Get-Contact | Select-Object DisplayName, Phone
    

    User's image

    2.Use the following command in PowerShell to get all contacts traversed and then delete their phone numbers.

    $contacts = Get-Contact -ResultSize Unlimited
    foreach ($contact in $contacts) {
        Set-Contact -Identity $contact.Identity -Phone ""
    }
    

    User's image

    1. Use the following command in PowerShell to confirm that the phone numbers of all contacts have all been deleted.
    Get-Contact | Select-Object DisplayName, Phone
    

    User's image

    Regarding Microsoft Entra, to better address your question, I will add a relevant tag to your post. Thank you for your support and understanding.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Best Wishes,

    Alex Zhang


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.