SOLVED

Command New-DistributionGroup doesn't work

Copper Contributor

Hi Guys,

 

I am really new with Powershell, so I apologise, if I can't be very clear with the description of my problem.

My Company uses Microsoft 365 and I wanted to use Powershell  and the command : 

New-DistributionGroup  -Name because I wanted to creat a Group for a RoomList.

I get the following error.

 

error.png

I connect to ExchangeOnline via powerShell:

Get-ExecutionPolicy

Set-ExecutionPolicy Unrestricted

Connect-ExchangeOnline

I Globlal Admin

I have installed the exchange module

Install-Module ExchangeOnlineManagement

in the powrshell help I can only find 3 commands with New-D but not the one mentioned in microsoft.

 

Hilfe.png

 

https://learn.microsoft.com/de-de/exchange/troubleshoot/calendars/conference-rooms-not-displayed

 

What am I doing wrong?

 

When use the Command Get-DistributionGroup, i can see the Details

Get.png

Many thanks in Advance.

Eduardo

 

6 Replies

@Eduardo_Ricardez 

 

Hi, Eduardo.

 

Don't worry about not seeing the command in the PowerShell ISE as by default it's only aware of modules installed on your computer at first. If you want to see the Exchange Online commandlets loaded as part of connecting, then you have to perform the connection inside the ISE, not outside of it, and then you'll see the module name in the list (prefixed with "tmpEXO" and then a randomised suffix) - as shown below:

 

LainRobertson_0-1691497405327.png

 

Putting the ISE to the side for a moment, here's three basic commandlets you can run from any old PowerShell prompt to incrementally check if you have access to the commandlets you're wanting to use:

 

 

# Connect to Exchange Online.
Connect-ExchangeOnline -Organization robertsonpayne.onmicrosoft.com -ShowBanner:$false;

# Quick confirmation that we're connected without issues - see the example screenshot below for the output from this command.
Get-ConnectionInformation | Format-Table -AutoSize -Property Name, Organization, TokenStatus, UserPrincipalName;

# Check if we can see any of the distribution list commandlets.
Get-Command -Module ((Get-Module -Name "tmpexo*").Name) -Name *distr*;

 

 

LainRobertson_1-1691497677009.png

 

 

If you don't find the ones you're after listed, then you don't have access and you'll need to step back and check your access rights - and that you're logged in with the correct account (as it's common in secured environments to have a separate account for performing administrative tasks) - before trying again.

 

Cheers,

Lain

@LainRobertson 

 

Hello Lain,

Thank you very much for your quick Response.
I have executed the commands you suggested and from the response I see on the screen, my accesses are correct and active.

In the last command I don't see: New-DistributionGroup, it means it doesn't exit ?

Resultado.png

Is the New-DistributionGroup command active for you?

Cheers,

 

Eduardo

best response confirmed by Eduardo_Ricardez (Copper Contributor)
Solution

@Eduardo_Ricardez 

 

Hi, Eduardo.

 

That's what I was expecting to hear.

 

The commandlet definitely exists, however, when you run Connect-ExchangeOnline, only the commandlets you have access to are loaded.

 

If you don't see a particular command, it means the account you have logged in with during Connect-ExchangeOnline does not have enough access to see and use that commandlet.

 

Using the following article's guidance, we can see which roles give access to New-DistributionGroup:

 

 

(Get-ManagementRole -Cmdlet New-DistributionGroup).Name |
    ForEach-Object {
        Get-ManagementRoleAssignment -Role $_ -Delegating:$false | Format-Table -AutoSize Role, RoleAssigneeType, RoleAssigneeName;
    }

 

Output:

LainRobertson_0-1691500030760.png

 

So, we can see from this that the account you logged in with using Connect-ExchangeOnline needs to be a member of either:

 

  • Organization Management
  • Recipient Management

 

The one thing that is for certain is that if you're not seeing the command, your account does not have the necessary rights to do so. It's not a problem with the commandlet not existing.

 

Cheers,

Lain

Lain,
You were right, I have now added the missing roles to the account and was able to use the New-DistributiuonGroup command.
Again thank you very much for your patience and help.

Cheers,
Eduardo

@Eduardo_Ricardez 

 

No problem!

 

Glad you got it sorted, and you'll get used to PowerShell quickly - you're doing fine already.

 

Cheers,

Lain

Hi @LainRobertson,@Eduardo_Ricardez

 

It works fine as per the given solution.

 

Now the point is how we can assign  "Organization Management" and "Recipient Management" role to an "Azure Application" to get an access for creating distribution group and the required functionality.

 

Thanks

1 best response

Accepted Solutions
best response confirmed by Eduardo_Ricardez (Copper Contributor)
Solution

@Eduardo_Ricardez 

 

Hi, Eduardo.

 

That's what I was expecting to hear.

 

The commandlet definitely exists, however, when you run Connect-ExchangeOnline, only the commandlets you have access to are loaded.

 

If you don't see a particular command, it means the account you have logged in with during Connect-ExchangeOnline does not have enough access to see and use that commandlet.

 

Using the following article's guidance, we can see which roles give access to New-DistributionGroup:

 

 

(Get-ManagementRole -Cmdlet New-DistributionGroup).Name |
    ForEach-Object {
        Get-ManagementRoleAssignment -Role $_ -Delegating:$false | Format-Table -AutoSize Role, RoleAssigneeType, RoleAssigneeName;
    }

 

Output:

LainRobertson_0-1691500030760.png

 

So, we can see from this that the account you logged in with using Connect-ExchangeOnline needs to be a member of either:

 

  • Organization Management
  • Recipient Management

 

The one thing that is for certain is that if you're not seeing the command, your account does not have the necessary rights to do so. It's not a problem with the commandlet not existing.

 

Cheers,

Lain

View solution in original post