forked from jaapbrasser/Events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.2.-.Lab.Exercises.ps1
84 lines (58 loc) · 1.3 KB
/
Module.2.-.Lab.Exercises.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#region Exercise 1
New-Variable -Name Text -Value 'Hello World!'
Write-Output -InputObject $Text
$Text | Get-Member
$Text.Length
$Text.Substring(4)
$Text.Substring
$Text.Substring(6,5)
#endregion
#region Exercise 2
$Array = 1..10
$Array[5]
$Array[5] = 'Six'
$Array = $Array + 11
$Array += 12
$Array
$Array | Get-Member | Select-Object -Property TypeName -Unique
$Date = Get-Date
$Array = $Array + $Date
$Array
#endregion
#region Exercise 3
$HashTable = @{
Key1 = 'value'
'N2' = '2nd value'
}
$HashTable
$HashTable.Third = 3
$HashTable
$PSObject = New-Object -TypeName PSCustomObject -Property @{
'Property1' = 1
'123' = 'onetwothree'
'Date' = Get-Date
}
$PSObject
$PSObject.NewProperty = 1
$String = '12345678'
$String[6..($String.Length)]
$String[6..999]
[pscustomobject]@{
1 = 'one'
2 = 'two'
}
New-Object -TypeName PSCustomObject -Property $HashTable
[pscustomobject]$HashTable
#endregion
#region Exercise 4
$String = 'The quick brown fox jumps over the lazy dog'
$String += 123
$String
$String -replace 'brown fox','polarbear'
"The string is: $String"
'The string is: $String'
'The string is: {0}' -f $String
'{0:X2}' -f 64
'{0:P2}' -f 0.66666
'{0:N2}' -f 3.99999
#endregion