/
HashTableExample.ps1
23 lines (20 loc) · 985 Bytes
/
HashTableExample.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#######################################################################
# Hash table #
# Just like an array but some differences.. Just check the difference #
#######################################################################
cls
$list = "PC1","10.0.0.1","iktspesialisten" # <- an array
# arrays do not have any definition. You cannot know that PC1 is a PC name
# 1. A simple hashtable (note, the word table).
cls
write-output "Here i have created a hash TABLE that has both the value and the name that goes with it to describe what the value is for.."
$hashtbl=@{Machine="PC1";IP="10.0.0.1";User="iktspesialisten}"} # <- an hashtable
$hashtbl
write-output ""
read-host "Please press Enter to continue..."
# 2. Accessing a specific element from the hashtable with the Name
cls
write-output "Here is a selected element by Name Machine."
$hashtbl.Machine
write-output ""
write-output "Please press Enter to continue..."