Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

How to update an attribute for AD users with a csv import?

$
0
0

I’m getting started with powershell. I found scripts from searching, but I learn best from doing something that’s relevant to my situation and then breaking it down.

That said, here’s what I got so far:

Import-Module ActiveDirectory $csv = Import-csv C:users.csv $Users | foreach { Get-ADUser -Identity $_.samaccountname | Set-ADUser -Replace @{'ipPhone'=$_.ipPhone} } 

The CSV file will have 2 columns and look like this:

sAMAccountName ipPhone User1 111111111 User2 122222222 

The first row is included in the csv file. Does the script execute on the first row as well?

Is there a way to do a dry run, where it doesn’t actually execute it, and also produces a log of what (would’ve) happened?

submitted by /u/PowerOverShelling
[link] [comments]

The post How to update an attribute for AD users with a csv import? appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles