protected override void ExecuteCmdlet()
        {
            var groupId = Identity.GetGroupId(HttpClient, AccessToken);

            Microsoft365GroupsUtility.ClearOwnersAsync(HttpClient, groupId, AccessToken).GetAwaiter().GetResult();
            var owners = Microsoft365GroupsUtility.GetOwnersAsync(HttpClient, groupId, AccessToken).GetAwaiter().GetResult();

            if (owners != null && owners.Any())
            {
                WriteWarning($"Clearing all owners is not possible as there will always have to be at least one owner. To changed the owners with new owners use Set-PnPMicrosoft365GroupOwner -Identity {groupId} -Owners \"[email protected]\"");
                WriteWarning($"Current owner is: {owners.First().UserPrincipalName}");
            }
        }
Example #2
0
        protected override void ExecuteCmdlet()
        {
            var owners = Microsoft365GroupsUtility.GetOwnersAsync(HttpClient, Identity.GetGroupId(HttpClient, AccessToken), AccessToken).GetAwaiter().GetResult();

            WriteObject(owners.OrderBy(o => o.DisplayName), true);
        }