-
Notifications
You must be signed in to change notification settings - Fork 1
/
6-Write-Information.ps1
46 lines (43 loc) · 1.33 KB
/
6-Write-Information.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
#region Setup
$question = 'Why does military parade data look so orderly?'
$answer = 'QgBlAGMAYQB1AHMAZQAgAGkAdAAnAHMAIABpAG4AIABmAG8AcgBtAGEAdABpAG8Abg' +
'AhAA=='
$answer = [System.Text.Encoding]::Unicode.GetString(
[System.Convert]::FromBase64String($answer))
#endregion Setup
# ==============================================================================
function demoInfo1 {
Get-ChildItem $pwd *-Write-*
Write-Information $question -InformationAction Continue
Write-Information $answer -InformationAction Continue
}
function demoInfo2 {
$MessageText = 'Here is the info for which you asked'
$Message1 = Write-Host $MessageText -ForegroundColor Cyan
$Message1
$Message2 = Write-Information $MessageText
$Message2
$Message3 = Write-Information $MessageText -InformationAction Continue
$Message3
# What is happening?
$Message4 = Write-Information $MessageText 6>&1
$Message4
# Is crossing streams what you really want to do?
Write-Information $MessageText -InformationVariable 'Message5'
$Message5
}
Wait-Debugger
demoInfo1
Wait-Debugger
$results = demoInfo1
$results | Get-Member | Select-Object -Unique TypeName
$results
Wait-Debugger
demoInfo1 6> Information.txt
Get-Content Information.txt
Wait-Debugger
$results = demoInfo1 6>&1
$results | Get-Member | Select-Object -Unique TypeName
$results
Wait-Debugger
demoInfo2