February 2019
Intermediate to advanced
626 pages
15h 51m
English
As with the hashtable, the Add method may be used to add a new value to a dictionary:
$dictionary.Add("Computer1", "192.168.10.222")
If the key already exists, using Add will generate an error, as was the case with the hashtable.
In a dictionary, the Contains method behaves differently from the same method in the hashtable. When checking for the existence of a key, the ContainsKey method should be used as follows:
if (-not $dictionary.ContainsKey("Computer2")) {
$dictionary.Add("Computer2", "192.168.10.13")
}
The dictionary supports the addition of elements using dot-notation:
$dictionary.Computer3 = "192.168.10.134"
The dictionary leverages PowerShell's type conversion for both the key and ...
Read now
Unlock full access