Solved

How to import profiles to update them?

Posted on 2014-09-15
3
90 Views
Last Modified: 2014-09-15
Hello,

I like to update an attributed in a profile for users in Active directory. I like to use the Import-Csv PowerShell command to do that. What would it look like if was going to update  one attribute name HireDate?  

Import-Csv .\users.csv   Not sure what would go here.

Users.scv would look like this:

GivenName,Surname,Name,DisplayName,SamAccountName,HireDate
Bob,Jones,Bob Jones,Bob Jones, bjones, 5/5/2000
0
Comment
Question by:PBIT
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
There is no HireDate attribute in AD (Unless you added a custom attribute using schema modification). You can update the HireDate in user description or notes. Following is an sample code to update the HireDate to user description.

Import-Module ActiveDirectory 
Import-Csv C:\User.csv | %{
 Set-ADUser $_.SamAccountName -Description $_.HireDate
}

Open in new window

0
 

Author Comment

by:PBIT
Comment Utility
Correct, the HireDate is a custom attributed added.  So, it would look like this?

Import-Module ActiveDirectory
Import-Csv C:\User.csv | %{Set-ADUser $_.SamAccountName -HireDate $_.HireDate}
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
There is no  -HireDate parameter for Set-ADUser command, try with following code..
Import-Csv C:\User.csv | %{Set-ADUser $_.SamAccountName –replace @{HireDate=$_.HireDate}}

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Mapping Drives using Group policy preferences Are you still using old scripts to map your network drives if so this article will show you how to get away for old scripts and move toward Group Policy Preference for mapping them. First things f…
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now