//
stai leggendo...
domanda

Setting AD attributes from a CSV file

strafico

Richard Siddaway's Blog

Back in this post http://richardspowershellblog.wordpress.com/2012/02/29/setting-a-users-home-directory/ I looked at setting the users home directory. I recently got a question about using a CSV file for input.

CSV files have been around for years and are likely to be with us for a long time to come – its a very useful and compact format.  using a CSV file to set attributes is a two stage process – read the data then make the changes.

I’ll use the home directory data as an example.  If you have a csv file with an entry for every user looking like this:

You can then do this:

Import-Csv .\homes.csv |
foreach {
Set-ADUser -Identity $_.samaccountname -HomeDirectory $_.Home  -HomeDrive $_.Drive -PassThru
}

If the attribute doesn’t have a parameter then:

Import-Csv .\homes.csv |
foreach {
Set-ADUser -Identity $_.samaccountname -Replace @{HomeDirectory = “$($_.Home)”; HomeDrive = “$($_.Drive)”}  -PassThru
}

View original post

Annunci

Discussione

Non c'è ancora nessun commento.

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: