Link to home
Start Free TrialLog in
Avatar of Garry Shape
Garry ShapeFlag for United States of America

asked on

Importing a CSV with First + Last Name and performing action

I'm trying to figure out how to, in PowerShell/Exchange PowerShell/Quest Powershell how to import a CSV that contains one column header is "user" and in the column is a list of employee First name and Last name, for example:
User
John Smith

Open in new window


I do:
$people = Import-Csv .\escalationlist.csv | %{$_.User}

Open in new window

then
get-qaduser $people

Open in new window


But I get:

Get-QADUser : Cannot convert 'System.Object[]' to the type 'Quest.ActiveRoles.ArsPowerShellSnapIn.Data.IdentityParamete
r' required by parameter 'Identity'. Specified method is not supported.
At line:1 char:12
+ Get-QADUser <<<<  $people
    + CategoryInfo          : InvalidArgument: (:) [Get-QADUser], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.GetUserCm
   dlet


If I could put quotes around $people then one would think it would work


Is there a way to lookup the AD username/account name based off this display name?
ASKER CERTIFIED SOLUTION
Avatar of Dale Harris
Dale Harris
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bradley Fox
Try this:


get-qaduser -Identity $people

get-qaduser -Identity '"$people"'

Open in new window

Avatar of Garry Shape

ASKER

Ah ok yes DaleHarris that works.

Do you know if the % sign in "$people = Import-Csv .\escalationlist.csv | %{$_.User}" means? Is that even necessary?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's awesome

But I'm trying to get the distinguished name from the display name. Trying this doesn't seem to work:

foreach ($user in $people) {$userDN =  get-qaduser $user | %{$_.distinguishedName}}

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah ok cool and I think my previous command was wrong, this seemed to work:

$people | Get-QADuser | %{$_.Directoryentry.distinguishedname}

And then that works with your solution, thanks again for your help