Functions/Set-MenuOption.ps1
|
<# .Synopsis Sets the options for the menu. .DESCRIPTION This function allows you to set various options for the menu, such as the fill character, colors, and text. .PARAMETER MenuFillChar The character to use for filling the menu. .PARAMETER MenuFillColor The color to use for filling the menu. .PARAMETER Heading The heading for the menu. .PARAMETER HeadingColor The color for the heading. .PARAMETER SubHeading The sub-heading for the menu. .PARAMETER SubHeadingColor The color for the sub-heading. .PARAMETER FooterText The text for the footer. .PARAMETER FooterTextColor The color for the footer text. .PARAMETER MenuItemColor The color for the menu items. .PARAMETER MenuNameColor The color for the menu name. .PARAMETER MaxWidth The maximum width of the menu. .PARAMETER MaxHeight The maximum height of the menu. .EXAMPLE Set-MenuOption -MenuFillChar "#" -MenuFillColor [ConsoleColor]::Blue .NOTES NAME: Set-MenuOption KEYWORDS: General scripting Controller Menu #> function Set-MenuOption { [cmdletbinding()] Param ( [string] $MenuFillChar = "*" , [ConsoleColor] $MenuFillColor = [consolecolor]::white , [string] $Heading = "[Heading not set]" , [ConsoleColor] $HeadingColor = [consolecolor]::white , [string] $SubHeading = "[SubHeading not set]" , [ConsoleColor] $SubHeadingColor = [consolecolor]::white , [string] $FooterText , [ConsoleColor] $FooterTextColor = [consolecolor]::white , [consolecolor] $MenuItemColor = [consolecolor]::white , [consolecolor] $MenuNameColor = [consolecolor]::white , [int] $MaxWidth = 80 , [int] $MaxHeight = 80 ) BEGIN { $f = $MyInvocation.InvocationName Write-Verbose -Message "$f - START" foreach ($key in $PSBoundParameters.Keys) { Write-Verbose -Message "$f - Setting [$key] to value $($PSBoundParameters.$key)" $script:MenuOptions.$key = $PSBoundParameters.$key } if ([string]::IsNullOrEmpty($script:MenuOptions.FooterText)) { if ($IsLinux -eq $true -or $IsMacOS -eq $true) { $currentUser = $env:USER if ([string]::IsNullOrWhiteSpace($currentUser)) { $currentUser = $env:HOME } $script:MenuOptions.FooterText = "$(Get-date) - Running as $currentUser" } else { $script:MenuOptions.FooterText = "$(Get-date) - Running as $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)" } } } END { Write-Verbose -Message "$f - END" } } |