poniedziałek, 22 kwietnia 2019

dynamic arrays in poweshell

By default arrays in Powershell are not dynamic, so the only way to deal with it is to use:
 
c:\>[System.Collections.ArrayList]$DynamicArray = @()
c:\>$DynamicArray.IsFixedSize 
False
c:\>$DynamicArray.Add("june")
c:\>$DynamicArray.Add("june")
c:\>$DynamicArray
june
june
c:\>$DynamicArray.Remove("june")
c:\>$DynamicArray
june
c:\>
We can pass this list to update membership in a group in Active Directory.
c:\>$DynamicArray = "january", "february", "march"
c:\>$DynamicArray += "april"
c:\>$DynamicArray += "april"
c:\>$DynamicArray
january
february
march
april
april
c:\>
So we can do it this way also.

Brak komentarzy:

Prześlij komentarz