I’ve got a bit of a weird one…
We have a group of field employees who are not part of the corporate office, and are not issued AD accounts or company email addresses. Because of the volume of turnover at these field locations, our HR department does notify us of each individual user activation/deactivation. Until now it didn’t matter because they did not have AD accounts. However…
As our business has grown, we are now using Concur, UltiPro, and several other systems that these field employees need access to. The way that HR wants to handle user on-boarding/off-boarding (and was agreed by leadership) is that they dump a CSV from their system with the necessary employee info to provision accounts, and have us pull this data to provision/de-provision accounts based on the “isactive” column. Straightforward, right? Here’s the twist… This CSV has multiple entries for employees that have changed roles/job titles within the company. One line shows that the user is inactive (old role), and the other shows active (current role). So I need help in figuring a way to remove accounts of inactives without removing the accounts of those who have only changed roles.
My idea: Set up an array of active users, and an array of inactive users and do some sort of comparison that only deactivates if the “isactive” column is not set to true in the other array. Something like:
$users = import-csv -path \\blah\thing.csv $inactiveusers = @() $activeusers = @() foreach ($user in $users) { if (($user.location -eq "Field") -and ($user.isactive -eq "true")) { $obj1 = [pscustomobject]@{"firstname"=$user.first; "lastname"=$user.last; "UPNPrefix"=$user.username; "location"=$user.location; "IsActive"=$user.isactive} $inactiveusers += $obj1 } } foreach ($user in $users) { if (($user.location -eq "Field") -and ($user.isactive -eq "true")) { $obj1 = [pscustomobject]@{"firstname"=$user.first; "lastname"=$user.last; "UPNPrefix"=$user.username; "location"=$user.location; "IsActive"=$user.isactive} $activeusers += $obj2 } }
From there, I need to come up with the logic to disable users who exist in $inactiveusers, but not in $activeusers…
So I guess 2 questions:
- is this a reasonable way to do this, or is there a better, more simplistic way?
- If this is reasonable, would anyone be able to help me with the comparative logic?
Sorry for such a long post, and thanks for any help!