/
Write-Functions.PS1
46 lines (40 loc) · 1.21 KB
/
Write-Functions.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
<#
Function Examples that can be imported using PowerShell Dot Sourcing
Assumign you saved this script to the C:\Scripts Directory this is how you would ingest the scripts.
set-location -path C:\Scripts
Now we use Dot Sourcing to import all the functions into global memory.
. .\Write-Functions.Ps1
#>
function write-GreenMessage {
[cmdletbinding()]
param(
[parameter(Mandatory=$false)]
[string]$Message
)
$originState = $Host.UI.RawUI.ForegroundColor
$Host.UI.RawUI.ForegroundColor = "Green"
Write-Output -inputobject $Message
$Host.UI.RawUI.ForegroundColor = $originState
}
function write-YellowMessage {
[cmdletbinding()]
param(
[parameter(Mandatory=$false)]
[string]$Message
)
$originState = $Host.UI.RawUI.ForegroundColor
$Host.UI.RawUI.ForegroundColor = "Yellow"
Write-Output -inputobject $Message
$Host.UI.RawUI.ForegroundColor = $originState
}
function write-RedMessage {
[cmdletbinding()]
param(
[parameter(Mandatory=$false)]
[string]$Message
)
$originState = $Host.UI.RawUI.ForegroundColor
$Host.UI.RawUI.ForegroundColor = "Red"
Write-Output -inputobject $Message
$Host.UI.RawUI.ForegroundColor = $originState
}