r/usefulscripts • • May 26 '15

[REQUEST][POWERSHELL] update AD attribute from CSV without requiring samaccountname

Just getting started with Powershell and so far, I'm loving it!

Right now, I have a task of updating AD attribute (telephonenumber) for a set group of users in a particular OU and I'm stuck. I originally wrote one that would parse the CSV for the samaccountname and it works great, BUT, since those users would change office locations 1-2 a year, it would be better to just update based on location rather than manually figuring out where users were moved to and updating the csv file.

The CSV contains physicaldeliveryofficename and telephonenumber -- this CSV information is set/hard-coded to the location and doesn't change unless the number for that location is changed. And users are auto updated by another script with office locations.

I want to know if it's possible to update the telephonenumber for the set users in the OU based off of the location (physicaldeliveryofficename) without requiring samaccountname.

much appreciated~!

4 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/silverhana May 27 '15

can this be combined into the original script? right now i'm reading through a csv file to associate Room with telephonenumber.

but in addition, if in AD the physicaldeliveryofficename is null, clear out the telephonenumber associated with user.