It’s so easy with powershell to create dynamic or static arrays.
For example;
$MyArray = 5, 6, 7
Just separate the items with commas.Another simple example;
$MyArray = “first”, “second”, “third”
If you want to add another item to the array just use;
$MyArray = $MyArray + “fourth”
To assign a range to the array;
$MyArray = 1..10
1..100 | ForEach { Net User "User$_" MyPassword=01 /ADD /Domain; Enable-Mailbox "User$_" }
This one creates bulk users with starts user + array range
To create an empty array and add items later;
$MyArray = @()
Array with values;
$MyArray = “to”, “day”, (get-date)
This gives following output



Anıl bey bilgilendirme için teşekkürler ama bu olusturdugumuz tam olarak ne array i oluyor? keşke onuda yazsaymışsınız
Link | January 6th, 2011 at 6:50 pm
Powershell scriptlerinizde kullanabileceğiniz bir yapı diyebiliriz.
Örneğin aynı anda 100 kullanıcı oluşturmak istediniz.Bunun için user1 user2 user3 gibi script yazmak yerine ben user kelimesini sabit tutarım ve bir array içerisindede 1-100 arası değerleri tanımlarım.Ardından scriptimde array için atadığım değişkeni kullanmak yetecektir.
Yada GUI tabanlı yazdığım ve yine yayınladığım update check scriptinde domaindeki tüm makineleri tek tek seçtirmek yerine bunların hepsini alan bir sorguyu array içerisine yerleştirip sonradan kullabilirim.
Link | January 7th, 2011 at 9:36 am