+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, EmloyeeID Powershell Script in Coding and Web Development; Hi everyone, was wondering if one of you could help me with this script. I have been asked to import ...
  1. #1
    Bezwick's Avatar
    Join Date
    Feb 2008
    Location
    Nottinghamshire
    Posts
    358
    Thank Post
    93
    Thanked 57 Times in 43 Posts
    Rep Power
    25

    Question EmloyeeID Powershell Script

    Hi everyone, was wondering if one of you could help me with this script.

    I have been asked to import our student SIMS id into the EmloyeeID attribute in Active Directory and have come across this little script.

    Import-module ActiveDirectory
    Import-CSV "C:\users.csv" | % {
    $User = $_.UserName
    $ID = $_.EmployeeID
    Set-ADUser $User -employeeID $ID
    }

    However it appears to only scan the default user OU at the root of the domain. Anyone know how to modify it so it scans all OU's in the active directory or at least what commands i need to add so that it can search a specific OU?

    Thanks

  2. #2
    ascott2's Avatar
    Join Date
    Nov 2007
    Posts
    183
    Thank Post
    18
    Thanked 38 Times in 30 Posts
    Rep Power
    21
    Strange as using a unique identifier like SAMAccountName, it shouldn't matter where it is, Set-ADUSer should find it. Out of interest if you modify your script to Get-ADUser rather than Set do you see the same results? If using get works you could modify your script to

    Import-module ActiveDirectory
    Import-CSV "C:\users.csv" | % {
    $User = $_.UserName
    $ID = $_.EmployeeID
    Get-ADUser $User | Set-ADUser -employeeID $ID
    }

  3. Thanks to ascott2 from:

    Bezwick (13th March 2013)

  4. #3
    Bezwick's Avatar
    Join Date
    Feb 2008
    Location
    Nottinghamshire
    Posts
    358
    Thank Post
    93
    Thanked 57 Times in 43 Posts
    Rep Power
    25
    That worked Thanks

    Quote Originally Posted by ascott2 View Post
    Strange as using a unique identifier like SAMAccountName, it shouldn't matter where it is, Set-ADUSer should find it. Out of interest if you modify your script to Get-ADUser rather than Set do you see the same results? If using get works you could modify your script to

    Import-module ActiveDirectory
    Import-CSV "C:\users.csv" | % {
    $User = $_.UserName
    $ID = $_.EmployeeID
    Get-ADUser $User | Set-ADUser -employeeID $ID
    }

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 2
    Last Post: 6th September 2013, 10:59 AM
  2. Replies: 2
    Last Post: 24th February 2011, 01:01 PM
  3. Replies: 0
    Last Post: 10th February 2011, 07:57 AM
  4. Powershell script to list printers with WPK
    By fawkers in forum Scripts
    Replies: 1
    Last Post: 17th November 2009, 09:55 AM
  5. Replies: 0
    Last Post: 24th January 2008, 02:58 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •