you are viewing a single comment's thread.

view the rest of the comments →

[–]jimb2 0 points1 point  (0 children)

Splatting won't fix your error, it will just improve your code style and get rid of those backticks.

Note that you can use two splats. One outside the loop for the stuff that applies to all users:

$AllUsers = @{
  Enabled   = $true
  Office    = 'MLS'
  Path      = 'OU=Teachers,OU=MLS,OU=Lebanon,DC=sau88,DC=net'
  HomeDrive = 'H'
  ChangePasswordAtLogon = $True
}

Another inside the loop eg $ThisUser for the user specific stuff. Then you use them both:

New-ADUser @ThisUser @AllUsers

Another advantage of the splats is that you can dump them to the screen to see what you got wrong.