I wouldn't be myself if I wouldn't add something from myself. You know, when you talk to your management about implementing something as simple as visual indicators there are (or at least should be) questions on how it will affect our brand, visually impacting how our Customers see us and how we see them. For that, I've prepared a little script. This script below is based on PSWriteHTML PowerShell Module that I've continued working on. While it's quite easy to get the text to be added as a visual indicator from your Manager things get complicated when you ask them about Colors. I, myself spend a lot of times playing with colors and it's real pain for me. Half of the time I am not sure which color will look good with another color making me go crazy. So… below, you get just that. It creates 2 files. One simple file with predefined colors, as below:
One a bit more complicated, with just 21000 colors. You see the visual indicator has four types of colors: Text, TextHeading, BorderColor, BackgroundColor. Initially, I thought it would be a good idea to have all those four types do color matching and see how it would look like, but then I did some math, and my concept died a bit. You see, my little colors library has only 147 named colors if you try to apply 147 colors per each type that gives you 466948881 (466 million of colors) colors. Even if I would leave PowerShell up and running for a few hours that would give me a large HTML file with output nobody would want to process with their own eyes to decide what is matching what (visually). Trying just three types gives you only 3176523 (3 million options), and while that seemed like I could probably make it, I doubt anyone wants to go thru that. So I only settled for 21609 possibilities. I decided that the border will be White and text color will be Black. While I can see you complaining, you're welcome to try it yourself and change the colors as you want them!
The file itself is 9MB of size when generated. On my computer, it took about 30 seconds to get this done. You can generate it on your own from the code below or you can use the one I generated on my computer from PSWriteHTML GitHub Examples.
Keep in mind you need PSWriteHTML for things to work. While you don't need it overall the generation part I created is using this little project of mine.
function Get-VisualIndicator {
[CmdLetBinding()]
param(
[string] $TextHeading,
[string] $Text,
[RGBColors] $Color = [RGBColors]::Black,
[RGBColors] $ColorBackground = [RGBColors]::DarkOrange,
[RGBColors] $ColorBorder = [RGBColors]::White,
[RGBColors] $ColorHeading = [RGBColors]::Black,
[switch] $TextHeadingBold,
[switch] $TextBold,
[switch] $SkipNewLine,
[switch] $Simplify
)
$RGBColorText = ConvertFrom-Color -Color $Color
$RGBColorBorder = ConvertFrom-Color -Color $ColorBorder
$RGBColorBackground = ConvertFrom-Color -Color $ColorBackground
$RGBColorHeading = ConvertFrom-Color -Color $ColorHeading
[string] $HTMLOutput = @(
if ($Simplify) {
$AttributesDiv = @{
'style' = @{
'width' = '100%'
'padding' = '2pt'
'font-size' = '11pt'
'line-height' = '12pt'
'font-family' = 'Calibri Light'
'color' = $RGBColorText
'text-align' = 'left'
'font-weight' = if ($TextBold) { 'bold' }
}
}
$AttributesSpanHeading = @{
'style' = @{
'color' = $RGBColorHeading
'font-weight' = if ($TextHeadingBold) { 'bold' }
}
}
New-HTMLTag -Tag 'div' -Attributes $AttributesDiv {
New-HTMLTag -Tag 'span' -Attributes $AttributesSpanHeading {
$TextHeading
}
$Text
}
if (-not $SkipNewLine) {
New-HTMLTag -Tag 'br' -SelfClosing
}
} else {
$AttributesDiv = @{
'style' = @{
'background-color' = $RGBColorBackground
'width' = '100%'
'border-style' = 'solid'
'border-color' = $RGBColorBorder
'border-width' = '1pt'
'padding' = '2pt'
'font-size' = '11pt'
'line-height' = '12pt'
'font-family' = 'Calibri Light'
'color' = $RGBColorText
'text-align' = 'left'
'font-weight' = if ($TextBold) { 'bold' }
}
}
$AttributesSpanHeading = @{
'style' = @{
'color' = $RGBColorHeading
'font-weight' = if ($TextHeadingBold) { 'bold' }
}
}
New-HTMLTag -Tag 'div' -Attributes $AttributesDiv {
New-HTMLTag -Tag 'span' -Attributes $AttributesSpanHeading {
$TextHeading
}
$Text
}
if (-not $SkipNewLine) {
New-HTMLTag -Tag 'br' -SelfClosing
}
}
)
return $HTMLOutput
}
Import-Module PSWriteHTML
$Output = @(
Get-VisualIndicator -TextHeading "WARNING:" -Text "The sender of this message could not be fully validated. The message may not be from the sender/domain displayed." -ColorBackground Orange
Get-VisualIndicator -TextHeading 'Caution:' -Text 'This email originated from outside the organisation. Please be mindful when opening attachments and embedded links.' -ColorBackground Red
Get-VisualIndicator -TextHeading "WARNING:" -Text "The sender of this message could not be fully validated. The message may not be from the sender/domain displayed." -ColorBackground Orange
Get-VisualIndicator -TextHeading 'Caution:' -Text 'This email originated from outside the organisation. Please be mindful when opening attachments and embedded links.' -ColorBackground Red
Get-VisualIndicator -TextHeading "WARNING:" -Text "The sender of this message could not be fully validated. The message may not be from the sender/domain displayed." -Simplify -Color Red -ColorHeading Red
Get-VisualIndicator -TextHeading 'Caution:' -Text 'This email originated from outside the organisation. Please be mindful when opening attachments and embedded links.' -Simplify -Color Orange -ColorHeading Orange
Get-VisualIndicator -TextHeading "WARNING:" -Text "The sender of this message could not be fully validated. The message may not be from the sender/domain displayed." -Simplify -Color Red -ColorHeading Red -TextHeadingBold
Get-VisualIndicator -TextHeading 'Caution:' -Text 'This email originated from outside the organisation. Please be mindful when opening attachments and embedded links.' -Simplify -Color Orange -ColorHeading Orange -TextHeadingBold
Get-VisualIndicator -TextHeading "WARNING:" -Text "The sender of this message could not be fully validated. The message may not be from the sender/domain displayed." -Simplify -Color Red -ColorHeading Red -TextHeadingBold -TextBold
Get-VisualIndicator -TextHeading 'Caution:' -Text 'This email originated from outside the organisation. Please be mindful when opening attachments and embedded links.' -Simplify -Color Orange -ColorHeading Orange -TextHeadingBold -TextBold
)
Save-HTML -FilePath $PSScriptRoot\TestColors.html -HTML $Output -ShowHTML
$Output = foreach ($Color1 in [RGBColors].GetEnumNames()) {
foreach ($Color2 in [RGBColors].GetEnumNames()) {
$RGB1 = ConvertFrom-Color -Color $Color1
$RGB2 = ConvertFrom-Color -Color $Color2
Get-VisualIndicator -SkipNewLine -TextHeading "WARNING: (Color Heading: $RGB1 ($Color1)" -Text "The sender of this message could not be fully validated. The message may not be from the sender/domain displayed. (ColorBackground $RGB2 ($Color2))" -ColorHeading $Color1 -ColorBackground $Color2
}
}
Save-HTML -FilePath $PSScriptRoot\TestColors147x2.html -HTML $Output -ShowHTML
<# Uncomment below if you dare - 147 x 147 x 147 colors.
$Time = Start-TimeLog
$Output = foreach ($Color1 in [RGBColors].GetEnumNames()) {
foreach ($Color2 in [RGBColors].GetEnumNames()) {
foreach ($Color3 in [RGBColors].GetEnumNames()) {
$RGB1 = ConvertFrom-Color -Color $Color1
$RGB2 = ConvertFrom-Color -Color $Color2
$RGB3 = ConvertFrom-Color -Color $Color3
Get-VisualIndicator -SkipNewLine -TextHeading "WARNING:" -Text "The sender of this message could not be fully validated. The message may not be from the sender/domain displayed. (Color Heading: $RGB1 ($Color1), ColorBackground $RGB2 ($Color2), TextColor $RBG3 ($Color3))" -ColorHeading $RGB1 -ColorBackground $RGB2 -Color $RGB3
}
}
}
Save-HTML -FilePath $PSScriptRoot\TestColors147x3.html -HTML $Output #-ShowHTML
Stop-TimeLog -Time $Time -Option OneLiner
#>
For those, brave enough I've left commented out code for the 3 million options. Take your shot!