Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
malauter committed Jan 2, 2024
1 parent b8eb173 commit a46f6d4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log for Microsoft365DSC

# UNRELEASED

* TeamsChannel
* Add error handling if GroupId of a team is null
FIXES [#3943](https://github.com/microsoft/Microsoft365DSC/issues/3943)

# 1.23.1227.1

* EXOAntiPhishPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,34 +385,41 @@ function Export-TargetResource
Write-Host "`r`n" -NoNewline
foreach ($team in $Teams)
{
$channels = Get-TeamChannel -GroupId $team.GroupId
$i = 1
Write-Host " |---[$j/$($Teams.Length)] Team {$($team.DisplayName)}"
foreach ($channel in $channels)
if($null -ne $team.GroupId)
{
Write-Host " |---[$i/$($channels.Length)] $($channel.DisplayName)" -NoNewline
$params = @{
TeamName = $team.DisplayName
GroupId = $team.GroupId
DisplayName = $channel.DisplayName
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
Credential = $Credential
$channels = Get-TeamChannel -GroupId $team.GroupId
$i = 1
Write-Host " |---[$j/$($Teams.Length)] Team {$($team.DisplayName)}"
foreach ($channel in $channels)
{
Write-Host " |---[$i/$($channels.Length)] $($channel.DisplayName)" -NoNewline
$params = @{
TeamName = $team.DisplayName
GroupId = $team.GroupId
DisplayName = $channel.DisplayName
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
Credential = $Credential
}
$Results = Get-TargetResource @Params
$Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode `
-Results $Results
$currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName `
-ConnectionMode $ConnectionMode `
-ModulePath $PSScriptRoot `
-Results $Results `
-Credential $Credential
$dscContent += $currentDSCBlock
Save-M365DSCPartialExport -Content $currentDSCBlock `
-FileName $Global:PartialExportFileName
$i++
Write-Host $Global:M365DSCEmojiGreenCheckMark
}
$Results = Get-TargetResource @Params
$Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode `
-Results $Results
$currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName `
-ConnectionMode $ConnectionMode `
-ModulePath $PSScriptRoot `
-Results $Results `
-Credential $Credential
$dscContent += $currentDSCBlock
Save-M365DSCPartialExport -Content $currentDSCBlock `
-FileName $Global:PartialExportFileName
$i++
Write-Host $Global:M365DSCEmojiGreenCheckMark
}
else
{
Write-Host " |---[$j/$($Teams.Length)] Team has no GroupId and will be skipped"
}
$j++
}
Expand Down

0 comments on commit a46f6d4

Please sign in to comment.