Wednesday, November 4, 2015

Working with Collections in PowerShell

If you have to work with Collections in PowerShell, you basically have 3 major options:

  1. Arrays
  2. ArrayLists
  3. Hashtables
Arrays are definitely the most common collections used in PowerShell scripts since they are built directly into the PowerShell framework and are by far the easiest to use: https://technet.microsoft.com/en-us/library/ee692791.aspx

Hashtables are similar to Dictionary collections and are also built directly into the PowerShell framework: https://technet.microsoft.com/en-us/library/ee692803.aspx?f=255&MSPPError=-2147217396

ArrayLists are NOT built into the PowerShell framework, but instead uses the capabilities of the .NET Framework in order to provide this functionality: https://technet.microsoft.com/en-us/library/ee692802.aspx.  However, given that you can tap into nearly any library that is provided by the .NET Framework using PowerShell, you could also potentially tap into Queues and Stacks as well! 

To learn more about Collections that are available with the .NET Framework, you can check out these articles:

https://msdn.microsoft.com/en-us/library/ybcx56wz.aspx

https://msdn.microsoft.com/en-us/library/0ytkdh4s%28v=vs.110%29.aspx



No comments:

Post a Comment