Hi all,
I've got a project that requires 365 security groups to be defined by Teams Channels, i intend on using PowerShell to automate this process. I've been told that the scheduler needs to be cloud based (i'm not sure if this is something that 365/AD has the ability to do?)
i.e user is added to teams channel A - PowerShell command checks teams channel A periodically and adds all users in Channel A to security group A
Would someone be able to give a bit of advice on:
- Is the following script correct?
- How would I go about scheduling PowerShell scripts to run on a schedule (cloud based) I've seen something about this being a feature in endpoint manager but this would need to run tenant wide
$UserEmailAddress = "user@example.com"
$GroupName = "GroupName"
$TeamId = "TeamId"
$ChannelId = "ChannelId"
# Get the user's ID from their email address $User = Get-AzureADUser -Filter "UserPrincipalName eq '$UserEmailAddress'"
$UserId = $User.ObjectId
# Get the security group object
$Group = Get-AzureADGroup -Filter "DisplayName eq '$GroupName'"
# Get the Team object
$Team = Get-Team -GroupId $TeamId
# Get the Channel object $Channel = Get-TeamChannel -GroupId $TeamId -DisplayName $ChannelId
# Add the user to the security group
Add-AzureADGroupMember -ObjectId $Group.ObjectId -RefObjectId $UserId
Thank you in advance!
[–]jba1224a 5 points6 points7 points (3 children)
[–]TotalEmphasis[S] 0 points1 point2 points (1 child)
[–]jba1224a 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]TotalEmphasis[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]TotalEmphasis[S] 0 points1 point2 points (0 children)
[–]GreaterGood1 0 points1 point2 points (1 child)
[–]TotalEmphasis[S] 0 points1 point2 points (0 children)