Hello world.
Its a programmer’s first words. Maybe not as a baby, but certainly when the programmer inside is born.
$Users = Import-Csv -Path $path #-Delimiter "|" if you export your CSVs with a delimeter of "|"
$target = @()
$Precheck = $Users.PsObject.Copy()
foreach ($User in $Precheck)
{
remove-variable SAM -ErrorAction SilentlyContinue
switch ($user.ou)
{
"it" {$user.ou = "OU=IT"}
"finance" {$user.ou = "OU=Finance"}
}
}
Additionally:
if (!($(try {get-adUser -Identity $SAM} catch {}))) {
$target += $user | select givenname,surname,emailaddress,campus,ou
}
else {
"User already exists! Skipping user $SAM"
}
With syntax hightlighter:
I’m keeping this post as it was when I first started my “blog” back in 2017. Maybe this time here in 2022 I’ll actually add content to the blog.