0 votes

I have tried using this Powershell script but it gives me this error image.png

image.png

by (40 points)

1 Answer

0 votes
by (294k points)

Hello,

The script can only be used in Adaxes 2021.1. Use the below script instead. For the script to work, install the Exchange EXO V2 module on the computer where Adaxes service runs.

Import-Module ExchangeOnlineManagement

$groupNames = @("MyGroup1", "MyGroup2", "MyGroup3")

try
{
    # Get the object ID in Microsoft 365
    $objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
    return # The user doesn't have a Microsoft 365 account
}

Connect-ExchangeOnline -Credential $Context.GetOffice365Credential()

foreach ($groupName in $groupNames)
{
    # Add user to group
    try
    {
        Add-DistributionGroupMember $groupName -Member $objectId.ToString() -BypassSecurityGroupManagerCheck -ErrorAction Stop
    }
    catch
    {
        $Context.LogMessage("An error occurred when adding the user to $groupName group. Error: " + $_.Exception.Message, "Warning")
    }
}

Related questions

0 votes
1 answer

Hi All, I was following the following documentation https://www.adaxes.com/tutorials_DelegatingPermissions_GrantRightsToModifyADGroupMembership.htm However I cannot work out how to make it ... can only add themselves. Any help would be great. Many Thanks

asked Mar 30, 2020 by antondubek (440 points)
0 votes
1 answer

Hi All, I am looking for a script i can use in adaxes, that removes all delegates for an exchange O365 mailbox, and reset their MFA tokens as well. I ... ($mailbox.Identity)" } } } # Disconnect from Exchange Online Disconnect-ExchangeOnline -Confirm:$false

asked Apr 18 by Brobertson92594 (20 points)
0 votes
1 answer

Hi Guys, You probably already met with a similar problem in your organization. Communications Department has dozens of distribution groups, that need to be updtaed base on some ... do the job. Maybe you can share some better solution to achieve same goal.

asked Mar 9, 2015 by axmaster (510 points)
0 votes
0 answers

Is it possible to do something such as this: When creating a user in the web interface, setup the form so that certain fields have a dropdown list of available values, ... "department", they would see a dropdown list of pre-populate options to choose from.

asked Aug 11, 2016 by HDClown (220 points)
0 votes
1 answer

I'm trying to automate adding users who are enrolled in MFA to an AD group. The scripts I found elsewhere here that do not work so I believe they may have been written against a prior Adaxes version or referencing a report that does not meet our needs.

asked May 31 by neal (50 points)
3,587 questions
3,275 answers
8,300 comments
548,052 users