Solved

Updating AD user fields from CSV file.

Posted on 2011-02-11
6
845 Views
Last Modified: 2012-05-11
This post is related to : http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_24870528.html#a34868508 

Just want to verify that I am understanding the syntax changes, say I want to update the description, telephone, and office, the syntax for the lower half would read as follows;

Import-CSV $Csv | ForEach-Object {
  Set-QADUser $_.DN -Description $_.description -Telephone $_.telephoneNumber -Office $_.physicalDeliveryOfficeName
}
0
Comment
Question by:nlewallen
  • 3
  • 3
6 Comments
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34872482

It'll be fine with that, yes.

The documentation for the CmdLet has it use PhoneNumber in place of Telephone:
Import-CSV $Csv | ForEach-Object {
  Set-QADUser $_.DN -Description $_.description -PhoneNumber $_.telephoneNumber -Office $_.physicalDeliveryOfficeName
}

Open in new window

But the parameter has an alias (TelephoneNumber) so it should work anyway.

Chris
0
 

Author Comment

by:nlewallen
ID: 34872695
Thank you Chris, I will test and get back to you.
0
 

Author Comment

by:nlewallen
ID: 34873688
Ran into a hiccup, was returned the following error:

$OuDomain = "dc=local,dc=testserver,dc=com" $Csv =
 "c:\importfile.csv" Import-CSV $Csv | ForEach-Object { Set-QADUser $_.DN -Descr
iption $_.description -PhoneNumber $_.telephoneNumber -Office $_.physicalDeliver
yOfficeName}
Unexpected token 'Csv' in expression or statement.
At line:1 char:48
+ $OuDomain = "dc=local,dc=testserver,dc=com" $Csv <<<<  = "c:\importfile.csv" I
mport-CSV $Csv | ForEach-Object { Set-QADUser $_.DN -Description $_.description
 -PhoneNumber $_.telephoneNumber -Office $_.physicalDeliveryOfficeName}
    + CategoryInfo          : ParserError: (Csv:String) [], ParentContainsErro
   rRecordException
    + FullyQualifiedErrorId : UnexpectedToken

[PS] C:\Users\llamallamaduck\Desktop>$_.physicalDeliveryOfficeName
}
    + CategoryInfo          : OpenError: (:) [Import-Csv], FileNotFoundExcepti
   on
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.Im
   portCsvCommand

Open in new window


When I converted the file to '.csv' I did receive an error message, but didn't think anything of it till now. I attached the error message file via picture. I am using Microsoft Excel 2010


excelError.jpg
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 70

Expert Comment

by:Chris Dent
ID: 34873730

You need some line breaks in there, are you trying to put it all on one line? PS will be quite happy spreading things out.
$OuDomain = "dc=local,dc=testserver,dc=com"
$Csv = "c:\importfile.csv" 
Import-CSV $Csv | ForEach-Object { 
  Set-QADUser $_.DN -Description $_.description -PhoneNumber $_.telephoneNumber -Office $_.physicalDeliveryOfficeName
}

Open in new window

If you just want to test the CSV file, run this:
Import-CSV "c:\importfile.csv"

Open in new window

Chris
0
 

Author Comment

by:nlewallen
ID: 34874134
I have bad luck apparently.

 [PS] C:\Users\llamallamaduck\Desktop>$OuDomain = "dc=local,dc=testserver,dc=com"
[PS] C:\Users\llamallamaduck\Desktop>$Csv = "c:\import.csv"
[PS] C:\Users\llamallamaduck\Desktop>Import-CSV $Csv | ForEach-Object {
>>   Set-QADUser $_.DN -Description $_.description -PhoneNumber $_.telephoneNumb
er -Office $_.physicalDeliveryOfficeName
>> }
>>
The term 'Set-QADUser' is not recognized as the name of a cmdlet, function, scr
ipt file, or operable program. Check the spelling of the name, or if a path was
 included, verify that the path is correct and try again.
At line:2 char:14
+   Set-QADUser <<<<  $_.DN -Description $_.description -PhoneNumber $_.telepho
neNumber -Office $_.physicalDeliveryOfficeName
    + CategoryInfo          : ObjectNotFound: (Set-QADUser:String) [], Command
   NotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException 

Open in new window


:S
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 250 total points
ID: 34874234

Ahh not really :)

You either need to install these:

http://www.quest.com/powershell/activeroles-server.aspx

Or if you already did, you need to run this command first of all:

Add-PsSnapIn Quest.ActiveRoles.ADManagement

That'll load the command and should let you execute the rest.

Chris
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This article explains how to install and use the NTBackup utility that comes with Windows Server.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

820 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