简体   繁体   中英

Office365: Follow in inbox powershell

Is there a way to write PowerShell command to "Follow in inbox" to a group?
or maybe Microsoft Graph API?

I am trying through the code to implement this feature, but can't see any
documentation.

In office 365 every user that joins a group can use the dropdown to select Follow in inbox or Stop following in inbox:

here an image example of follow in inbox

I dont know a possiblity to do that via Powershell. You can set it in the AdminCenter gui of Office365 in the group settings.

See here: https://docs.microsoft.com/en-us/office365/admin/create-groups/create-groups?view=o365-worldwide#how-following-group-email-works

Update:

It seems that you can do it with the Graph API: https://docs.microsoft.com/en-us/graph/api/group-update?view=graph-rest-1.0

Function "UpdateGroup" and the Setting "autoSubscribeNewMembers".

Note: This will only take effect for new members not for existing ones!

Thank you, Hannes
This is a PowerShell I wrote:

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session

<#Get all Office 365 Groups that AutoSubscribeNewMembers disabled#>
$O365Groups = Get-UnifiedGroup | Where-Object{$_.AutoSubscribeNewMembers -eq $false}

<#Iterate through the Groups, enabling the AutoSubscribeNewMember#>
foreach ($group in $O365Groups)
{
Set-UnifiedGroup $group.Identity -AutoSubscribeNewMembers:$true
}

<#Close the Session#>
Remove-PSSession $Session

Works fine only for new member in the group

I was searching for the opposite command, to unsubscribe a user manually from powershell due to an external user receiving the emails for a group that were unnecessary to send externally.

Here are the powershell commands, connected to Exhange Online Powershell version 2:

View subscribers:

Get-UnifiedGroupLinks -Identity <email address> -LinkType Subscribers

Add subscribers:

Add-UnifiedGroupLinks -Identity <email address> -LinkType Subscribers -Links <comma separated list of email addresses>

Remove subscribers:

Remove-UnifiedGroupLinks -Identity <email address> -LinkType Subscribers -Links <comma separated list of email addresses>

Documentation

I have been working on some sample commands for this exact topic: Unsubscribe-FollowInInbox.ps1 (for full list of code samples)

Some samples:

#Check subscription status for ALL unified groups
Get-UnifiedGroup | Format-Table Name,*subscribe* -AutoSize

Here is PowerShell to make all "members" in to "subscribers" (aka Follow In Inbox)

##########################################
#  Loop 1 - SUBSCRIBE all group members  #
##########################################

#Store the team name in a variable. Change this to match your team. 
#To find this for your team, use (Get-UnifiedGroup *test-team*).PrimarySmtpAddress
$teamname = "test-team@example.com"

#Find all the members of the Unified Group "test-team" and store their UserMailbox objects in a variable called "members"
$members = Get-UnifiedGroup $teamname | Get-UnifiedGroupLinks -LinkType Member

#Create a variable to keep track of how many members we have subscribed or unsubscribed
$membercount = ($members.Count)

#Loop through the list of members and add a subscriber link for each one
foreach ($member in $members) 
{
    #Decrement the member count
    $membercount--
    
    #Write progress to the PowerShell window
    Write-Host "Adding subscriber link for user $($member.PrimarySmtpAddress), $membercount users remaining"
    
    #Add the UnifiedGroupLink to make each user a subscriber
    Add-UnifiedGroupLinks -Identity $teamname -Links $($member.PrimarySmtpAddress) -LinkType Subscriber -Confirm:$false
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM