forked from stcu/SharedScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Write-Info.ps1
35 lines (34 loc) · 1.14 KB
/
Write-Info.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<#
.SYNOPSIS
Writes to the information stream, with color support and more.
#>
#Requires -Version 5.1
[CmdletBinding()] Param(
# Message to write to the information stream.
[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] $Message,
# Specifies the text color. There is no default.
[Alias('fg')][Nullable[ConsoleColor]] $ForegroundColor,
# Specifies the background color. There is no default.
[Alias('bg')][Nullable[ConsoleColor]] $BackgroundColor,
<#
The string representations of the input objects are concatenated to form the output.
No spaces or newlines are inserted between the output strings.
No newline is added after the last output string.
#>
[switch] $NoNewLine,
<#
By default, uses -InformationAction Continue.
This uses the standard $InformationPreference instead.
#>
[switch] $UseInformationPreference
)
Process
{
if(!$UseInformationPreference) {$Local:InformationPreference = 'Continue'}
Write-Information ([Management.Automation.HostInformationMessage]@{
Message = $Message
ForegroundColor = $ForegroundColor
BackgroundColor = $BackgroundColor
NoNewLine = $NoNewLine
})
}