August 16th, 2014

PowerTip: Change Value of Element in PowerShell Array

Doctor Scripto
Scripter

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

Hey, Scripting Guy! Question How can I use Windows PowerShell to change the value of the first element in an array?

Hey, Scripting Guy! Answer Use the Set method and specify the element number and the new value, for example:

PS C:\> $a = 1,2,3,4,5

PS C:\> $a.Set(0,50)

Category
Scripting

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.