File tree Expand file tree Collapse file tree 1 file changed +36
-2
lines changed
Modules/CIPPCore/Public/Standards Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,42 @@ function Invoke-CIPPStandardAddDKIM {
3333 param ($Tenant , $Settings )
3434 # $Rerun -Type Standard -Tenant $Tenant -API 'AddDKIM' -Settings $Settings
3535
36- $AllDomains = (New-ExoRequest - tenantid $Tenant - cmdlet ' Get-AcceptedDomain' ).DomainName
37- $DKIM = (New-ExoRequest - tenantid $Tenant - cmdlet ' Get-DkimSigningConfig' ) | Select-Object Domain, Enabled, Status
36+
37+ $DkimRequest = @ (
38+ @ {
39+ CmdletInput = @ {
40+ CmdletName = ' Get-AcceptedDomain'
41+ Parameters = @ {}
42+ }
43+ },
44+ @ {
45+ CmdletInput = @ {
46+ CmdletName = ' Get-DkimSigningConfig'
47+ Parameters = @ {}
48+ }
49+ }
50+ )
51+
52+ $BatchResults = New-ExoBulkRequest - tenantid $Tenant - cmdletArray $DkimRequest - useSystemMailbox $true
53+
54+ # Check for errors in the batch results. Cannot continue if there are errors.
55+ $ErrorCounter = 0
56+ $ErrorMessages = [System.Collections.Generic.List [string ]]::new()
57+ $BatchResults | ForEach-Object {
58+ if ($_.error ) {
59+ $ErrorCounter ++
60+ $ErrorMessage = Get-NormalizedError - Message $_.error
61+ $ErrorMessages.Add ($ErrorMessage )
62+ }
63+ }
64+ if ($ErrorCounter -gt 0 ) {
65+ Write-LogMessage - API ' Standards' - tenant $Tenant - message " Failed to get DKIM config. Error: $ ( $ErrorMessages -join ' , ' ) " - sev Error
66+ return
67+ }
68+
69+
70+ $AllDomains = ($BatchResults | Where-Object { $_.DomainName }).DomainName
71+ $DKIM = $BatchResults | Where-Object { $_.Domain } | Select-Object Domain, Enabled, Status
3872
3973 # List of domains for each way to enable DKIM
4074 $NewDomains = $AllDomains | Where-Object { $DKIM.Domain -notcontains $_ }
You can’t perform that action at this time.
0 commit comments