Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell - Bulk Set-ADUser attributes via a CSV file

$
0
0
I am attempting to do a Bulk replace of AD User account attributes via a CSV file.  Each line in this script works except the part of Set-ADUser where I enter -Replace $attribs. I'm not sure how to code this part.



<#
The .csv file should have the following headers (first line)
GroupName,Status,Approver1,Approver2,Owner
#>
#Import CSV
$csv = @()
$csv = Import-Csv -Path "C:\TempAdd_Grp_Attrib.csv"
#Loop through all items in the CSV
ForEach ($item In $csv) 
    {
      $gname = $item.GroupName
      $attribs = @{'extensionAttribute2'=$item.Status; 'extensionAttribute3'=$item.Approver1; 'extensionAttribute4'=$item.Approver2; 'managedBy'=$item.Owner}
      Set-ADGroup -Identity $gname #-Replace $attribs
    }




mamadukes


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>