Changing Access Type via PowerShell

Deleted
Not applicable

I need to change all Public Groups to Provate Groups. So I am attempting to run:

 

Get-UnifiedGroup | Where {$_.AccessType -eq "Public"} | Set-UnifiedGroup -AccessType Private

 

I keep getting this error:

 

A parameter cannot be found that matches parameter name 'AccessType'.

 

Anyone experienced this?

17 Replies

Mmm...very weird, I have just pasted your PS code in the PowerShell console and I have not had any error...however I'm seeing a warning seeing that the comand execution finished correctly, but not configuration has been modified for every group on the tenant. If I run the Set-UnifiedGroup "Group Name" -AccessType "Public" it works without problems....and also to add, it's not enougt (I believe) to be Global Administrator to change this setting for each Group. You need to be an Owner in each Group...adding some more folks here @Tony Redmond @Christophe Fiessinger @Vasil Michev

And more funny stuff: PowerShell says that the Group I changed to Public is Public...but the UI says it's Privated (Previous status)...^-^

I just tried it here and was able to run Set-UnifiedGroup to set the access type for a group from public to private and vice versa.

Ey Tony I have just verified that the change was finally done, so it seems it can take some time to propagate the change from public to private for a Group when using PowerShell...Is it correct you need to be a Group owner to change the status or any other property for the Group additionally to the Global Admin role?

A group owner can change group properties.

 

A global tenant administrator can change the properties of any group.

 

The change should happen immediately. Whether the UI of a client picks the change up and displays that change is entirely a different matter - clients do cache properties and it all depends on how often they check with AAD to ensure what the values of the properties actually are...

Thanks Tony, I was with the idea that you could need to be a Group owner :-)...it's always good to ask for confirmation. In regards of change in the groups status it could be I was having an issue on my tenant because I even did some In private sessions using the UI and the changes done in PowerShell were not reflected as expected

Yeah, could be that. OWA refresh of group properties is the likely issue here.

When using PowerShell with ISE I don't even get access to tthe -AccessType Paramater to use? I have tested in a demo tenant and seem to have access. But when trying this through a prod tenant even though the account is a global admin -AccessType is not available.

 

There is another issue in play here in that the organisations email is on premise and NOT in Exchange Online adn there is NO Hybrid set up either. All these groups have created as a result of users accessing Planner and creating Plans.

I don't know how you have connected to Exchange Online using PowerShell ISE. It's odd that the -AccessType parameter is unavailable. Is it the same with the normal PowerShell console?

 

Even though users might use another email system (non-hybrid, outside Office 365) for their day-to-day email, do they have Exchange Online mailboxes? If they are assigned something like an E3 license, they will get an Exchange mailbox automatically... So the mailboxes might be there and are linked to Office 365 accounts but are not being used.

So I am running this in a demo tenant and it works

 

$userCredential = Get-Credential
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $session
Set-UnifiedGroup -Identity "Name here" -AccessType Private

 

When running the same commands in a prod tenant there is no ability to use the -AccessType Parameter....

So I have tried in a number of different tentants all with Global Administrator Accounts.

 

In some tenants I get this (-AccessType Parameter is available):

 

NoAccessType.PNG

In other tenants I get this (No -AccessType Paramater available)

 

AccessType.PNG

 

Of course the tenant I need to change AccessType on is one of the ones that does not have access to this parameter for some reason....Frustrating. Any insights, thoughts, ideas etc would be greatly appreciated.

I don't think this is a First Release thing because the AccessType parameter has been around for quite a while. I do think this is something you need to report to Microsoft in a support call as only they can resolve the issue.

On a similar topic I wrote this recently:

#...................................
# Variables:
#   Cut off date in days
#   Classification
#...................................
$cutoffdate = ((Get-Date).AddDays(-10))
$classification = "High"

# Retrieve recently created groups with accesstype set to PUBLIC
$Groups = Get-UnifiedGroup | Where-Object {
    $_.WhenCreated -ge $cutoffdate -and $_.AccessType -eq 'Public' -and $_.Classification -eq $classification } `
     | Sort-Object whencreated | Select DisplayName, WhenCreated, AccessType, Classification, ManagedBy

# For each new group update set accesstype to PRIVATE
ForEach ($G in $Groups) { 
    Set-UnifiedGroup -Identity $G.DisplayName -AccessType 'Private'
    Write-Host "The following Group privacy setting was updated:" $G.DisplayName
}

 

Hi @Christophe Fiessinger my issue is that in some tenants I do not have access to this parameter -AccessType for some reason? Any clues?

Not sure why, as @Tony mentioned please contact support to get this addressed using the proper channel.

Yeah have done.....

is there anyway to keep the Public Group but prevent users from using the email feature and be able to become members by themselves going to the the members section and click on join ?