-
Notifications
You must be signed in to change notification settings - Fork 1
/
5-Write-Debug.ps1
40 lines (36 loc) · 1002 Bytes
/
5-Write-Debug.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
#region Setup
$question = 'What did one developer say to the other when they increased ' +
'logging and found the error?'
$answer = 'SQB0ACcAcwAgAGQAZQBiAHUAZwAuAA=='
$answer = [System.Text.Encoding]::Unicode.GetString(
[System.Convert]::FromBase64String($answer))
#endregion Setup
# ==============================================================================
function demoDebug1 () {
[CmdletBinding()]
param()
Write-Debug $question
Write-Debug $answer
}
function demoDebug2 () {
[CmdletBinding()]
param()
$fileInfo = Get-ChildItem -Path $PSScriptRoot -Filter '*.ps1'
foreach ($item in $fileInfo) {
Write-Verbose "Processing file: $($item.FullName)"
Write-Debug $($item | Select-Object * | Out-String)
}
}
Wait-Debugger
demoDebug1 -Debug
# Wait-Debugger
demoDebug1 -Debug 5> Debug.txt
Get-Content Debug.txt
Wait-Debugger
demoDebug2
Wait-Debugger
demoDebug2 -Verbose
Wait-Debugger
demoDebug2 -Verbose -Debug
Wait-Debugger
demoDebug2 -Verbose -Debug 5> FileDebug.txt