@@ -34,6 +34,7 @@ function Invoke-CIPPStandardUserSubmissions {
3434
3535 # Get state value using null-coalescing operator
3636 $state = $Settings.state.value ?? $Settings.state
37+ $Email = Get-CIPPTextReplacement - TenantFilter $Tenant - Text $Settings.email
3738
3839 # Input validation
3940 if ($Settings.remediate -eq $true -or $Settings.alert -eq $true ) {
@@ -42,8 +43,8 @@ function Invoke-CIPPStandardUserSubmissions {
4243 return
4344 }
4445
45- if (! ([string ]::IsNullOrWhiteSpace($Settings .email ))) {
46- if ($Settings .email -notmatch ' @' ) {
46+ if (! ([string ]::IsNullOrWhiteSpace($Email ))) {
47+ if ($Email -notmatch ' @' ) {
4748 Write-LogMessage - API ' Standards' - tenant $Tenant - message ' UserSubmissions: Invalid Email parameter set' - sev Error
4849 return
4950 }
@@ -54,7 +55,7 @@ function Invoke-CIPPStandardUserSubmissions {
5455 $RuleState = New-ExoRequest - tenantid $Tenant - cmdlet ' Get-ReportSubmissionRule'
5556
5657 if ($state -eq ' enable' ) {
57- if (([string ]::IsNullOrWhiteSpace($Settings .email ))) {
58+ if (([string ]::IsNullOrWhiteSpace($Email ))) {
5859 $PolicyIsCorrect = ($PolicyState.EnableReportToMicrosoft -eq $true ) -and
5960 ($PolicyState.ReportJunkToCustomizedAddress -eq $false ) -and
6061 ($PolicyState.ReportNotJunkToCustomizedAddress -eq $false ) -and
@@ -63,13 +64,13 @@ function Invoke-CIPPStandardUserSubmissions {
6364 } else {
6465 $PolicyIsCorrect = ($PolicyState.EnableReportToMicrosoft -eq $true ) -and
6566 ($PolicyState.ReportJunkToCustomizedAddress -eq $true ) -and
66- ($PolicyState.ReportJunkAddresses -eq $Settings .email ) -and
67+ ($PolicyState.ReportJunkAddresses -eq $Email ) -and
6768 ($PolicyState.ReportNotJunkToCustomizedAddress -eq $true ) -and
68- ($PolicyState.ReportNotJunkAddresses -eq $Settings .email ) -and
69+ ($PolicyState.ReportNotJunkAddresses -eq $Email ) -and
6970 ($PolicyState.ReportPhishToCustomizedAddress -eq $true ) -and
70- ($PolicyState.ReportPhishAddresses -eq $Settings .email )
71+ ($PolicyState.ReportPhishAddresses -eq $Email )
7172 $RuleIsCorrect = ($RuleState.State -eq ' Enabled' ) -and
72- ($RuleState.SentTo -eq $Settings .email )
73+ ($RuleState.SentTo -eq $Email )
7374 }
7475 } else {
7576 if ($PolicyState.length -eq 0 ) {
@@ -87,13 +88,12 @@ function Invoke-CIPPStandardUserSubmissions {
8788 $StateIsCorrect = $PolicyIsCorrect -and $RuleIsCorrect
8889
8990 if ($Settings.remediate -eq $true ) {
90-
9191 # If policy is set correctly, log and skip setting the policy
9292 if ($StateIsCorrect -eq $true ) {
9393 Write-LogMessage - API ' Standards' - tenant $Tenant - message ' User Submission policy is already configured' - sev Info
9494 } else {
9595 if ($state -eq ' enable' ) {
96- if (([string ]::IsNullOrWhiteSpace($Settings .email ))) {
96+ if (([string ]::IsNullOrWhiteSpace())) {
9797 $PolicyParams = @ {
9898 EnableReportToMicrosoft = $true
9999 ReportJunkToCustomizedAddress = $false
@@ -107,14 +107,14 @@ function Invoke-CIPPStandardUserSubmissions {
107107 $PolicyParams = @ {
108108 EnableReportToMicrosoft = $true
109109 ReportJunkToCustomizedAddress = $true
110- ReportJunkAddresses = $Settings .email
110+ ReportJunkAddresses = $Email
111111 ReportNotJunkToCustomizedAddress = $true
112- ReportNotJunkAddresses = $Settings .email
112+ ReportNotJunkAddresses = $Email
113113 ReportPhishToCustomizedAddress = $true
114- ReportPhishAddresses = $Settings .email
114+ ReportPhishAddresses = $Email
115115 }
116116 $RuleParams = @ {
117- SentTo = $Settings .email
117+ SentTo = $Email
118118 }
119119 }
120120 } else {
0 commit comments