About Me

My photo
HANUMANGARH, RAJASTHAN, India
Showing posts with label AD User Update. Show all posts
Showing posts with label AD User Update. Show all posts

Tuesday, 20 December 2022

Update User properties in Active Directory from CSV

 

  1. Import-Module ActiveDirectory
  2. $USERS = Import-CSV c:\users.csv
  3. $USERS | foreach {
  4. $empid=$_.employeeid
  5. $company=$_.company
  6. $title=$_.title
  7. $department=$_.department
  8. $Division=$_.division
  9. $pobox=$_.pobox
  10. $city=$_.city
  11. Set-ADUSer -Identity $_.samaccountname -Replace @{employeeID=$empid; company=$company; title=$title; department=$department; division=$division; postofficebox=$pobox; l=$City}
  12. }


=====================================================================================================

Import-Module ActiveDirectory

$USERS = Import-CSV c:\users.csv

$empid=$USERS.employeeid
$company=$USERS.company
$title=$USERS.title
$department=$USERS.department
$Division=$USERS.division
$pobox=$USERS.pobox
$city=$USERS.city
$acc=$USERS.samaccountname

ForEach ($user in $USERS) {
Get-ADUser -Filter "samaccountname -eq '$Acc'" | Foreach {
Set-ADUser $ -Replace @{title = $title}
Set-ADUser $
 -Replace @{company = $company}
Set-ADUser $ -Replace @{department = $department}
Set-ADUser $
 -Add @{division = $division}
Set-ADUser $ -Replace @{postOfficeBox = $pobox}
Set-ADUser $
 -Replace @{l = $city}
Set-ADUser $_ -Replace @{employeeid = $empid}
}
}

Extract Disk Info from Remote host

 # Define the remote hostname or IP address $remoteHost = Get-Content "C:\temp\RemoteServer.txt" # Define the output CSV file path...