Filter Already Archived Teams
Hi,
I have a script to add MS groups that are teams enabled to a SP list.
However it’s adding items that are already archived, I only want it to add items that haven’t been archived?
I am getting the usage records and checking if that group ID has an ID also in Teams so I know that it’s a teams enabled group or not.
I think there is a isArchived parameter in Get-Team that could be used but I don’t know how to write the code?
# Check and validate each M365 Group
#
#####
ForEach ($UsageRecord in $UsageData) {
Write-Output “Proceed list entry $($Counter) from $($Count)…”
if ($UsageRecord.’Is Deleted’ -eq “True”) {
$Counter++
continue
}
# Get Group ID and validate if it is Teams enabled
$GroupId = $UsageRecord.”Group Id”
$TeamsEnabled = $AllTeams | Where-Object {$_.Id -eq $GroupId}
if (!$TeamsEnabled) {
Write-Output “M365 Group with Id $($GroupId) is not Teams enabled- skip this record”
continue
}
$Archived = $AllTeams | Where-Object ($_.Id -eq $GroupId )
Thanks,
Richard
Hi, I have a script to add MS groups that are teams enabled to a SP list. However it’s adding items that are already archived, I only want it to add items that haven’t been archived? I am getting the usage records and checking if that group ID has an ID also in Teams so I know that it’s a teams enabled group or not. I think there is a isArchived parameter in Get-Team that could be used but I don’t know how to write the code? # Check and validate each M365 Group
#
#####
ForEach ($UsageRecord in $UsageData) {
Write-Output “Proceed list entry $($Counter) from $($Count)…”
if ($UsageRecord.’Is Deleted’ -eq “True”) {
$Counter++
continue
}
# Get Group ID and validate if it is Teams enabled
$GroupId = $UsageRecord.”Group Id”
$TeamsEnabled = $AllTeams | Where-Object {$_.Id -eq $GroupId}
if (!$TeamsEnabled) {
Write-Output “M365 Group with Id $($GroupId) is not Teams enabled- skip this record”
continue
}
$Archived = $AllTeams | Where-Object ($_.Id -eq $GroupId ) Thanks,Richard Read More