powershell:qnd:powershell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
powershell:qnd:powershell [2023/02/02 17:29] – [Hash Table] mguptonpowershell:qnd:powershell [2024/10/24 14:24] (current) – [Select Objects] mgupton
Line 97: Line 97:
  
 ==== Hash Table ==== ==== Hash Table ====
-  * To loop over the items in a hash table one options is to call ''GetEnumerator()'' on the hash table.+  * To loop over the items in a hash table one option is to call ''GetEnumerator()'' on the hash table.
  
 <code powershell> <code powershell>
Line 103: Line 103:
  
 foreach ($i in $t1.GetEnumerator()) { foreach ($i in $t1.GetEnumerator()) {
-    $i+    $i.value 
 +
 +</code> 
 + 
 +=== Alternatively use the keys === 
 + 
 +<code powershell> 
 +$t1 = @{firstname = "Michael"; lastname = "Muse"
 + 
 +foreach ($i in $t1.keys) { 
 +    $t1[$i]
 } }
 </code> </code>
Line 121: Line 131:
 Example of getting just the first item of the listed output Example of getting just the first item of the listed output
 <code powershell> <code powershell>
-ls | select first 1+ls | select -first 1
 </code> </code>
  
  • powershell/qnd/powershell.1675358995.txt.gz
  • Last modified: 2023/02/02 17:29
  • by mgupton