forked from jdhitsolutions/PSScriptTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrite-Detail.ps1
More file actions
54 lines (50 loc) · 1.43 KB
/
Write-Detail.ps1
File metadata and controls
54 lines (50 loc) · 1.43 KB
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
Function Write-Detail {
[cmdletbinding()]
Param(
[Parameter(Position = 0, Mandatory)]
[string]$Message,
[ValidateSet("BEGIN","PROCESS","END")]
[string]$Prefix = "PROCESS",
[switch]$NoDate
)
$pfx = $($Prefix.ToUpper()).PadRight("process".length)
if ($Nodate) {
$dt = (Get-Date -Format "hh:mm:ss:ffff")
}
else {
$dt = "{0} {1}" -f (Get-Date).ToShortDateString(),(Get-Date -Format "hh:mm:ss:ffff")
}
$Text = "$dt [$pfx] $Message"
Write-Output $Text
} #close Write-Detail
Function Out-VerboseTee {
[CmdletBinding()]
Param(
[Parameter(Mandatory,ValueFromPipeline)]
[object]$Value,
[Parameter(Position=0,Mandatory)]
[string]$Path,
[System.Text.Encoding]$Encoding,
[switch]$Append
)
Begin {
#turn on verbose pipeline since if you are running this command you intend for it to be on
$VerbosePreference = "continue"
}
Process {
#only run if Verbose is turned on
if ($VerbosePreference -eq "continue") {
$Value | Out-String | Write-Verbose
$PSBoundParameters.Remove("Append") | Out-Null
if ($Append) {
Add-Content @PSBoundParameters
}
else {
Set-Content @PSBoundParameters
}
}
}
End {
$VerbosePreference = "silentlycontinue"
}
} #close Out-VerboseTee