0

I'm semi-new to PowerShell, so please excuse if I mix up some terminology. I need to manage M365-Groups via PS. I've inherited a productive machine which had a very old ExchangeOnlineModule installed (v. 0.4578.0). This version did allowed me to read the M365-Group members via get-unifiedGroupLinks -identity "zzz.test" -LinkType Members, but not to add members.

Next installed the latest productive version of the ExchangeOnlineMangement module according to MS' manual. The command

Get-InstalledModule

shows me version 2.0.5. The command

Get-Module -ListAvailable

shows both old an new version, installed in "Directory: C:\Program Files\WindowsPowerShell\Modules"

When I now try to run the following Add-command, I receive the error below:

Add-UnifiedGroupLinks -Identity "zzz.test" -LinkType Members -Links "mytestuser@mydomain.com"
Add-UnifiedGroupLinks : The term 'Add-UnifiedGroupLinks' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, 
verify that the path is correct and try again.
At line:1 char:1
+ Add-UnifiedGroupLinks -Identity "zzz.test" -LinkType Members -Link ...
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Add-UnifiedGroupLinks:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 

Same after I "manually" import that specific module version with "Import-Module".

Can anyone help me understand why this command works on my test machine, but is simply not recognized on this one? I already restarted that productive machine after the installation.

Thank you in advance & best regards

MK

TacoCat88
  • 21
  • 4
  • Does it still show running `Get-Module` by itself? – Abraham Zinala Sep 07 '22 at 15:12
  • Good point - yes, it shows (with correct version 2.0.5) as one of 7 entries when I run ```Get-Module``` by itself – TacoCat88 Sep 07 '22 at 15:18
  • Did you connect to Exchange Online beforehand? – Abraham Zinala Sep 07 '22 at 15:25
  • Yessir, connected. The Get-UnifiedGroupLinks command does still work after the Module update. When I try the Add-command right after that - no joy. – TacoCat88 Sep 07 '22 at 15:29
  • Okay, last questions. Are you using an Exchange Management Shell? Can you show me how you connected to exchange? – Abraham Zinala Sep 07 '22 at 15:46
  • No, I'm using the regular ISE, connecting with ```Connect-ExchangeOnline -UserPrincipalName "myadmin@mydomain.com"```. I'll be using the Add-commands in an Azure runbook later down the line. – TacoCat88 Sep 08 '22 at 06:07
  • That is the issue. You have you use an Exchange Shell, or a session connected to exchange. – Abraham Zinala Sep 08 '22 at 12:24
  • I am having a session connected to Exchange, as I can read out group memberships. However, some testing today showed, that it most likely has to do with insufficient access rights. As "Global administrator" role I can read and write to M365-Groups, as "Groups administrator" role I receive the misleading "cmd not found" error, when trying to write. – TacoCat88 Sep 08 '22 at 13:13
  • According to [ExchangePowerShell](https://learn.microsoft.com/en-us/powershell/module/exchange/?view=exchange-ps), you need an Exchange Shell, or using a PSSession; see note on that link. – Abraham Zinala Sep 08 '22 at 14:20
  • I was refering to the ExchangeOnlineManagement, aka "Exchange Online Powershell V2 Module", mentioned in the same note. The rest of the note talks about onprem Exchange, as far as I understand. However, I found the cause in insufficient access rights – TacoCat88 Sep 09 '22 at 05:59

1 Answers1

1

Figured it with testing: The issue was insufficient access rights in AzureAD for the user used to connect to Exchange Online.

It would seem that the module only loads the commands for which you have the access rights to use into the connected session. Therefor, when you try to use such a command (like Add-UnifiedGroupLins) you get a "Term is not recognized" error, instead of something meaningfull.

For those who care: It worked for me after adding the Exchange administrator role and, obviously, with the Global administrator role. Maybe there is a lesser role that is sufficient, but I haven't found it.

TacoCat88
  • 21
  • 4