-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwriteOutput.ps1
70 lines (58 loc) · 1.74 KB
/
writeOutput.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# A function to make colored output easily
# The available colors are
# 1. Black
# 2. Blue
# 3. Cyan
# 4. DarkBlue
# 5. DarkCyan
# 6. DarkGray
# 7. DarkGreen
# 8. DarkMagenta
# 9. DarkRed
# 10. DarkYellow
# 11. Gray
# 12. Green
# 13. Magenta
# 14. Red
# 15. White
# 16. Yellow
function writeOutput {
<#
.PARAMETER foregroundColor
This means the foreground color of the output text.
.PARAMETER backgroundColor
This means the background color of the output text.
.PARAMETER text
This means the text that you want to show output.
#>
# The "Default" the default parameter set for the function.
# The "Default" the default parameter set for the function.
[CmdletBinding(DefaultParameterSetName = "Default")]
param (
[Parameter(ParameterSetName = "Custom")]
[ValidateSet("Black", "Blue", "Cyan", "DarkBlue",
"DarkCyan", "DarkGray", "DarkGreen", "DarkMagenta",
"DarkRed", "DarkYellow", "Gray", "Green",
"Magenta", "Red", "White", "Yellow")]
[string]
$foregroundColor,
[Parameter(ParameterSetName = "Custom")]
[ValidateSet("Black", "Blue", "Cyan", "DarkBlue",
"DarkCyan", "DarkGray", "DarkGreen", "DarkMagenta",
"DarkRed", "DarkYellow", "Gray", "Green",
"Magenta", "Red", "White", "Yellow")]
[string]
$backgroundColor,
[Parameter(ValueFromRemainingArguments)]
[string]
$text
)
switch ($PSCmdlet.ParameterSetName) {
Custom {
Write-Host -BackgroundColor $backgroundColor -ForegroundColor $foregroundColor $text;
}
Default {
Write-Host -BackgroundColor White -ForegroundColor Black $text;
}
}
}