Advertisement
wetyukmnbxc

Dictionary

Mar 27th, 2023
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. Here is an example of creating a dictionary data structure in Powershell.
  2.  
  3. $dict = @{
  4. Key1 = 'Value1';
  5. Key2 = 'Value2';
  6. Key3 = 'Value3'
  7. }
  8.  
  9. # Access the Value of a Key
  10. $dict['Key1']
  11.  
  12. # Add a Key-Value Pair
  13. $dict['Key4'] = 'Value4'
  14.  
  15. # Remove a Key-Value Pair
  16. Remove-Item $dict['Key3']
  17.  
  18. # Loop Through the Dictionary
  19. foreach ($value in $dict.Values) {
  20. Write-Output $value
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement