video stop at 1h
This commit is contained in:
@@ -64,6 +64,7 @@ Command-1 | Command-2
|
||||
"May the force be with you!" | Out-File forewithwho.txt
|
||||
```
|
||||
|
||||
|
||||
## Variables
|
||||
|
||||
They start with a "$"
|
||||
@@ -81,4 +82,61 @@ $x + $y
|
||||
|
||||
$FavCharacter | Select-Object -Property *
|
||||
# output all the Property of the variable
|
||||
Get-Member -InputObject $FaveCharacter
|
||||
# output all the mehtods you can use
|
||||
```
|
||||
|
||||
## Arrays
|
||||
|
||||
A collection of variables
|
||||
|
||||
```powershell
|
||||
$Jedi = @('Obi-Wan Kenobi', 'Luke Skywalker', 'Master Yoda', 'Mace Windu')
|
||||
|
||||
$Jedi.GetType()
|
||||
# output Object[]
|
||||
|
||||
$Jedi[0]
|
||||
# output : Obi-Wan Kenobi
|
||||
|
||||
$Jedi[0].Length
|
||||
# output 14
|
||||
|
||||
$Jedi += 'Qui-Gon Jin'
|
||||
# add a variable to the array
|
||||
```
|
||||
|
||||
## hash table
|
||||
|
||||
Specify keys
|
||||
|
||||
```powershell
|
||||
$FellowshipBeta = @{key1 = "item1"; key2 = "item2"}
|
||||
|
||||
$Fellowship = @{"Wizard" = "Gandalf"; "Elf" = "Legolas"; "Hobbit" = "Frodo"}
|
||||
|
||||
$Fellowship.Add("Dwarf", "Gimli")
|
||||
# for adding an element
|
||||
|
||||
$Fellowship.Set_Item("Dwarf", "Bilbo")
|
||||
# changing an element
|
||||
|
||||
$Fellowship."Dwarf"
|
||||
$Fellowship.["Dwarf"]
|
||||
# retrieve an element
|
||||
|
||||
$Fellowship.Remove("Dwarf")
|
||||
# Remove an element
|
||||
```
|
||||
|
||||
## Read-Host
|
||||
for having user iput
|
||||
|
||||
## Evaluatig
|
||||
|
||||
```powershell
|
||||
|
||||
$PokemonCaught = "908"
|
||||
If($PokemonCaught -eg 908) { Write-Host "You're a Pokemon Master! "}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user