Private/BrowserAuthPages.ps1
|
function New-InTUIBrowserAuthPageContent { [CmdletBinding()] param( [Parameter(Mandatory)] [string]$Title, [Parameter(Mandatory)] [string]$Heading, [Parameter(Mandatory)] [string]$Message ) [pscustomobject]@{ Title = $Title Heading = $Heading Message = $Message } } function Get-InTUIBrowserAuthDefaultPageContent { [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateSet('Success', 'Error')] [string]$Type ) if ($Type -eq 'Success') { return New-InTUIBrowserAuthPageContent ` -Title 'Authentication Successful - InTUI' ` -Heading 'Authentication Successful' ` -Message 'You can close this window and return to PowerShell.' } return New-InTUIBrowserAuthPageContent ` -Title 'Authentication Failed - InTUI' ` -Heading 'Authentication Failed' ` -Message 'Please close this window and try again.' } function Resolve-InTUIBrowserAuthPageContent { [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateSet('Success', 'Error')] [string]$Type, [Parameter()] [object]$Content ) if ($null -eq $Content) { return Get-InTUIBrowserAuthDefaultPageContent -Type $Type } foreach ($propertyName in @('Title', 'Heading', 'Message')) { $propertyValue = $Content.PSObject.Properties[$propertyName]?.Value if ([string]::IsNullOrWhiteSpace([string]$propertyValue)) { throw "Browser auth page content is missing $propertyName." } } return [pscustomobject]@{ Title = [string]$Content.Title Heading = [string]$Content.Heading Message = [string]$Content.Message } } function Get-InTUIBrowserAuthHtml { [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateSet('Success', 'Error')] [string]$Type, [Parameter()] [object]$Content ) $isSuccess = $Type -eq 'Success' $content = Resolve-InTUIBrowserAuthPageContent -Type $Type -Content $Content $title = [System.Net.WebUtility]::HtmlEncode($content.Title) $heading = [System.Net.WebUtility]::HtmlEncode($content.Heading) $message = [System.Net.WebUtility]::HtmlEncode($content.Message) $background = if ($isSuccess) { 'linear-gradient(135deg, #1e66f5 0%, #209fb5 100%)' } else { 'linear-gradient(135deg, #d20f39 0%, #fe640b 100%)' } $symbol = if ($isSuccess) { '✓' } else { '✕' } $logo = @' ██╗███╗ ██╗████████╗██╗ ██╗██╗ ██║████╗ ██║╚══██╔══╝██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██║ ██║██║ ██║██║ ╚████║ ██║ ╚██████╔╝██║ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝ '@ return @" <html> <head> <meta charset='UTF-8'> <title>$title</title> <style> body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: $background; } .container { text-align: center; color: white; } .brand { font-size: 14px; letter-spacing: 4px; margin-bottom: 22px; opacity: 0.9; } .version { font-size: 12px; opacity: 0.7; } .logo { display: inline-block; margin: 0 0 18px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: clamp(10px, 2vw, 18px); line-height: 1.05; letter-spacing: 0; text-align: left; white-space: pre; text-shadow: 0 8px 30px rgba(0, 0, 0, 0.22); } .tagline { margin: 0 0 26px 0; opacity: 0.82; font-size: 15px; } .icon { font-size: 52px; margin-bottom: 18px; } h1 { margin: 0 0 10px 0; font-weight: 300; font-size: 28px; } p { margin: 0; opacity: 0.9; font-size: 16px; } </style> </head> <body> <div class='container'> <div class='brand'>[ I N T U I ] <span class='version'>v$script:InTUIVersion</span></div> <pre class='logo'>$logo</pre> <p class='tagline'>Intune Terminal User Interface</p> <div class='icon'>$symbol</div> <h1>$heading</h1> <p>$message</p> </div> </body> </html> "@ } |