Skip to main content

Posts

Showing posts with the label Users

PowerShell Script: Update AD attributes using CSV

Hi All, in this post I am going to share information on how can you update an attribute(s) in AD for multiple objects. In this post, I am using a CSV file that contains users’ First Name, Last Name, their login name and Employee ID. I wanted to update Employee ID for all the users listed in CSV file. To achieve this, I have complied a PowerShell script that uses CSV file and update AD attributes for multiple users. CSV file: I saved CSV file in C:\ADTest.CSV . I ran following PowerShell script as admin. This script import CSV data, updates EmployeeID data for each login name (sAMAccountName) listed in CSV file. #Import Active Directory module Import-Module ActiveDirectory #Import CSV file $Obj = Import-Csv "C:\ADTest.csv" foreach ( $Usr in $Obj ) { Get-ADUser -Filter "sAMAccountName -eq ' $( $u . sAMAccountName) '" -properties * | set-aduser -replace @{employeeID = " $( $u . employeeID) " } -

PowerShell command to export a list of domain users from AD group to a CSV file

Here I go with another post on PowerShell. This time, I would like to share a PowerShell command that will help you to export list of users of particular AD (Active Directory) group to a CSV file. Run PowerShell and type following commands: # This will import ActiveDirectory module Import-Module ActiveDirectory # This command will export list of users from GroupName to a CSV file Get-ADGroupMember -Identity "GroupName" -server "TestDomain" -recursive | get-aduser -Properties mail | select name , samaccountname | export-csv -path c:\Script\report.csv -NoTypeInformation In above command, replace GroupName with the Group you want to retrieve members list. Type your domain name in place of TestDomain . Once you run above command, it will create a CSV file “ Report.CSV ” and save it in C:\Script folder. I hope you find this post very useful. Disclaimer: www.TechieTalks.co.uk does not conceal the possibility of error and shortc