How to Bulk Update Users Employee ID from an Excel File on Active Directory using Powershell

Jnarthan Govindasamy 5 Reputation points
2024-03-06T04:45:05.8133333+00:00

Hi,

User's image

Does anyone knows how to use script to add employee ID in Active Directory Server using Window Powershell?

Please help me!!!

Thanks

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,562 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,503 questions
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,131 questions
Active Directory Federation Services
Active Directory Federation Services
An Active Directory technology that provides single-sign-on functionality by securely sharing digital identity and entitlement rights across security and enterprise boundaries.
1,219 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,444 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,591 Reputation points
    2024-03-06T16:23:13.1766667+00:00

    Something like this:

    Import-Csv |
        ForEach-Object{
            $e = Get-ADUser -filter "employeeno = '$_.'EMPLOYEE NO'"
            if ($e){
                $e | Set-ADUser -EmployeeID $_.'NameOfEmployeeIDColumnInCSV'
            }
        }
    

    I don't see anything in the CSV that can be used as an Identity in the Get-ADUser, so I used a filter and "employeeno" as the AD property name -- you should verify that it's the correct property name. If there's a column in your spreadsheet that has can be used as a unique Identity (distinguished name, objectGUID, objectSid, or saMAccountName) then you should eliminate the need for the Get-ADUser and just use a Set-ADUser with the "-Identity" parameter.

    0 comments No comments