@@ -54,6 +54,22 @@ function Invoke-CIPPStandardBranding {
5454 $Localizations = New-GraphGetRequest - Uri " https://graph.microsoft.com/beta/organization/$ ( $TenantId.customerId ) /branding/localizations" - tenantID $Tenant - AsApp $true
5555 # Get layoutTemplateType value using null-coalescing operator
5656 $layoutTemplateType = $Settings.layoutTemplateType.value ?? $Settings.layoutTemplateType
57+
58+ $SetSignInPageText = -not [string ]::IsNullOrEmpty($Settings.signInPageText )
59+ $SetUsernameHintText = -not [string ]::IsNullOrEmpty($Settings.usernameHintText )
60+
61+ $BrandingBody = [ordered ]@ {
62+ loginPageTextVisibilitySettings = [pscustomobject ]@ {
63+ hideAccountResetCredentials = $Settings.hideAccountResetCredentials
64+ }
65+ loginPageLayoutConfiguration = [pscustomobject ]@ {
66+ layoutTemplateType = $layoutTemplateType
67+ isHeaderShown = $Settings.isHeaderShown
68+ isFooterShown = $Settings.isFooterShown
69+ }
70+ }
71+ if ($SetSignInPageText ) { $BrandingBody [' signInPageText' ] = $Settings.signInPageText }
72+ if ($SetUsernameHintText ) { $BrandingBody [' usernameHintText' ] = $Settings.usernameHintText }
5773 # If default localization (id "0") exists, use that to get the currentState. Otherwise we have to create it first.
5874 if ($Localizations | Where-Object { $_.id -eq ' 0' }) {
5975 try {
@@ -71,18 +87,7 @@ function Invoke-CIPPStandardBranding {
7187 AsApp = $true
7288 Type = ' POST'
7389 ContentType = ' application/json; charset=utf-8'
74- Body = [pscustomobject ]@ {
75- signInPageText = $Settings.signInPageText
76- usernameHintText = $Settings.usernameHintText
77- loginPageTextVisibilitySettings = [pscustomobject ]@ {
78- hideAccountResetCredentials = $Settings.hideAccountResetCredentials
79- }
80- loginPageLayoutConfiguration = [pscustomobject ]@ {
81- layoutTemplateType = $layoutTemplateType
82- isHeaderShown = $Settings.isHeaderShown
83- isFooterShown = $Settings.isFooterShown
84- }
85- } | ConvertTo-Json - Compress
90+ Body = [pscustomobject ]$BrandingBody | ConvertTo-Json - Compress
8691 }
8792 $CurrentState = New-GraphPostRequest @GraphRequest
8893 } catch {
@@ -92,22 +97,18 @@ function Invoke-CIPPStandardBranding {
9297 }
9398 }
9499
95- $StateIsCorrect = ($CurrentState.signInPageText -eq $Settings.signInPageText ) -and
96- ($CurrentState.usernameHintText -eq $Settings.usernameHintText ) -and
97- ($CurrentState.loginPageTextVisibilitySettings.hideAccountResetCredentials -eq $Settings.hideAccountResetCredentials ) -and
100+ $StateIsCorrect = ($CurrentState.loginPageTextVisibilitySettings.hideAccountResetCredentials -eq $Settings.hideAccountResetCredentials ) -and
98101 ($CurrentState.loginPageLayoutConfiguration.layoutTemplateType -eq $layoutTemplateType ) -and
99102 ($CurrentState.loginPageLayoutConfiguration.isHeaderShown -eq $Settings.isHeaderShown ) -and
100- ($CurrentState.loginPageLayoutConfiguration.isFooterShown -eq $Settings.isFooterShown )
103+ ($CurrentState.loginPageLayoutConfiguration.isFooterShown -eq $Settings.isFooterShown ) -and
104+ (-not $SetSignInPageText -or ($CurrentState.signInPageText -eq $Settings.signInPageText )) -and
105+ (-not $SetUsernameHintText -or ($CurrentState.usernameHintText -eq $Settings.usernameHintText ))
101106
102- $CurrentValue = [PSCustomObject ]@ {
103- signInPageText = $CurrentState.signInPageText
104- usernameHintText = $CurrentState.usernameHintText
107+ $CurrentValue = [ordered ]@ {
105108 loginPageTextVisibilitySettings = $CurrentState.loginPageTextVisibilitySettings | Select-Object - Property hideAccountResetCredentials
106109 loginPageLayoutConfiguration = $CurrentState.loginPageLayoutConfiguration | Select-Object - Property layoutTemplateType, isHeaderShown, isFooterShown
107110 }
108- $ExpectedValue = [PSCustomObject ]@ {
109- signInPageText = $Settings.signInPageText
110- usernameHintText = $Settings.usernameHintText
111+ $ExpectedValue = [ordered ]@ {
111112 loginPageTextVisibilitySettings = [pscustomobject ]@ {
112113 hideAccountResetCredentials = $Settings.hideAccountResetCredentials
113114 }
@@ -117,6 +118,16 @@ function Invoke-CIPPStandardBranding {
117118 isFooterShown = $Settings.isFooterShown
118119 }
119120 }
121+ if ($SetSignInPageText ) {
122+ $CurrentValue [' signInPageText' ] = $CurrentState.signInPageText
123+ $ExpectedValue [' signInPageText' ] = $Settings.signInPageText
124+ }
125+ if ($SetUsernameHintText ) {
126+ $CurrentValue [' usernameHintText' ] = $CurrentState.usernameHintText
127+ $ExpectedValue [' usernameHintText' ] = $Settings.usernameHintText
128+ }
129+ $CurrentValue = [pscustomobject ]$CurrentValue
130+ $ExpectedValue = [pscustomobject ]$ExpectedValue
120131
121132 if ($Settings.remediate -eq $true ) {
122133 if ($StateIsCorrect -eq $true ) {
@@ -129,18 +140,7 @@ function Invoke-CIPPStandardBranding {
129140 AsApp = $true
130141 Type = ' PATCH'
131142 ContentType = ' application/json; charset=utf-8'
132- Body = [pscustomobject ]@ {
133- signInPageText = $Settings.signInPageText
134- usernameHintText = $Settings.usernameHintText
135- loginPageTextVisibilitySettings = [pscustomobject ]@ {
136- hideAccountResetCredentials = $Settings.hideAccountResetCredentials
137- }
138- loginPageLayoutConfiguration = [pscustomobject ]@ {
139- layoutTemplateType = $layoutTemplateType
140- isHeaderShown = $Settings.isHeaderShown
141- isFooterShown = $Settings.isFooterShown
142- }
143- } | ConvertTo-Json - Compress
143+ Body = [pscustomobject ]$BrandingBody | ConvertTo-Json - Compress
144144 }
145145 $null = New-GraphPostRequest @GraphRequest
146146 Write-LogMessage - API ' Standards' - Tenant $Tenant - Message ' Successfully updated branding.' - Sev Info
0 commit comments