Forum Discussion
SX
Feb 18, 2025Copper Contributor
The term 'New-MailContact' is not recognized
Hi Support, I am trying to bulk import external contacts to the tenant. I have come across several other Q&As which have the similar issue. However, the issue is slightly different - I have assigne...
LainRobertson
Mar 01, 2025Silver Contributor
Hi SX,
You're correct in that under default conditions, New-MailContact should be available for members of the Recipient Management role, however, it would pay to check that holds true for your environment.
Here's a couple of commands you can use to validate which roles permit access to New-MailContact as well as cross-check the RBAC memberships your test account currently holds.
Note the inline comment pertaining to leveraging the -CmdletParameters parameter, as Exchange Online filters beyond the base commandlet and into the actual parameter usage.
# Microsoft Learn reference:
# https://learn.microsoft.com/en-us/powershell/exchange/find-exchange-cmdlet-permissions?view=exchange-ps#use-powershell-to-find-the-permissions-required-to-run-a-cmdlet
# Use this command to verify which roles can run a given command. It may pay to also add in the -CmdletParameters to get a more granular response from Exchange Online.
Get-ManagementRole -Cmdlet "New-MailContact" | ForEach-Object {
Get-ManagementRoleAssignment -Role $_.Name -Delegating $false | Select-Object -Property Role, RoleAssigneeType, RoleAssigneeName;
} | Format-Table -AutoSize;
# Use this command to enumerate the members of all roles, which you can use to cross-check the test account's current role-based access.
Get-RoleGroup | ForEach-Object {
$Role = $_;
Get-RoleGroupMember -Identity $_.Identity | ForEach-Object {
[PSCustomObject] @{
Role = $Role.Name;
Type = $_.RecipientType;
Member = $_.Identity;
}
}
}
Cheers,
Lain