Friday, August 28, 2020

How to Create an array with user input in PowerShell


$arr =@() #Create a variable for array
Write-Host "how many numbers you  want in An Array" 
[int]$LenOfArray = Read-Host  #User Input
for ($i=0;$i -lt $LenOfArray$i++)
{
  $num = Read-Host "Enter $i Index number";
 $arr +=$num
}
Write-Host "The Array is $arr"

No comments:

Post a Comment

Featured post

System-preferred multifactor authentication (MFA)

Popular Posts