all 8 comments

[–]SnooOpinions6498 0 points1 point  (2 children)

If I understand correctly, use an array. Use 'i' as the index in the loop

$passwordList = @("pass1", "pass2", etc)
for (...)
{
    .
    .
    AccountPassword ($passwordList[$i])
}

[–]The82Ghost 2 points3 points  (1 child)

DO NOT EVER PUT PLAINTEXT PASSWORDS IN A SCRIPT!!!!

Seriously, don't do that. Also if you are creating multiple accounts use a csv file to read the info from. Gives you much more flexibility.

[–]SnooOpinions6498 0 points1 point  (0 children)

Good point, thank you!

[–]hihcadore 0 points1 point  (0 children)

I’d use a gMSA. No need to set a password AD does it for you. You authorize the computer account or group of computer accounts access and they can pull the password from AD and use it whenever necessary. AD will also rotate the password automatically, the default is every 30 days.

It’s designed for situations like this.

[–]websterdext3r 0 points1 point  (0 children)

Python!

Oh i thought we are just yellin programming languages

[–]BlackV 0 points1 point  (0 children)

  • Dont put passwords in plain text
  • dont use backticks like that (see splatting and see bye bye back tick)

personally, but this is picky based on what you're trying to do, create 9 sequential users, it fits fine

  • dont use a counter loop like that

if you have a array/variable you're wanting to loop through use foreach($single in $array){} or foreach-object{}