How to add the Department to Mail contact via powershell

IT 140 Reputation points

I managed to create a new mail contact with the below command:

New-MailContact -Name "Parents of SAM KAM" -FirstName SAM -LastName KAM -ExternalEmailAddress "" -Alias SAM_KAM_Parents

Then I got a request to add Department. I found the below option on Microsoft website, but it did not work out

-Department Year7

This example configures the Title, Department, Company, and Manager properties for the mail contact Kai Axford.


Set-Contact "Kai Axford" -Title Consultant -Department "Public Relations" -Company Fabrikam -Manager "Karen Toh"

I got the below error when I run my cmd:

New-MailContact -Name "Parents of SAM KAM" -FirstName SAM -LastName KAM -ExternalEmailAddress "" -Alias SAM_KAM_Parents

exchange error

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,365 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,449 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 99,936 Reputation points MVP

    You cannot use the -Department parameter as part of the creation process, you can only set it after the mail contact has been created. First run the New-MailContact cmdlet as in your first example, and once the contact has been created follow it up by:

    Set-Contact "Parents of SAM KAM" -Department Year7

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful