Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Change Value of Element in Array with PowerShell

$
0
0

Summary: Learn how to use Windows PowerShell to change the value of an element in an array.

Hey, Scripting Guy! Question How can I use Windows PowerShell to update one of the values in one of the elements of an array?

Hey, Scripting Guy! Answer Use the Item method to retrieve the element and assign a new value. Here is an example of
           updating the value of the first element in an array:

$a = 1,2,3,4,5

$a.Item(0) = 12

$a

Note  Remember that in Windows PowerShell, all arrays are zero-based. This means that the first
element is actually element 0.


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>