Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Powershell / Quest userID grab?

Reply
 
Old 10-26-2007   #1 (permalink)
Ian_1


 
 

Powershell / Quest userID grab?

In either Quest or Powershell, is there a way to feed it a .csv file and some
form of a list of usernames to get their userID's? I've got this huge list of
names then I need to get their ID , and was trying to figure out a way to
extract all the user names for them into a new file. Thanks

My System SpecsSystem Spec
Old 10-26-2007   #2 (permalink)
Brandon Shell [MVP]


 
 

Re: Powershell / Quest userID grab?

Can you clarify what you mean by UserID?

Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject

I> In either Quest or Powershell, is there a way to feed it a .csv file
I> and some form of a list of usernames to get their userID's? I've got
I> this huge list of names then I need to get their ID , and was trying
I> to figure out a way to extract all the user names for them into a new
I> file. Thanks
I>


My System SpecsSystem Spec
Old 10-26-2007   #3 (permalink)
Ian_1


 
 

Re: Powershell / Quest userID grab?

Taking a list of names - "IE Jones, Amanda;Smith, John;Terrel, mike" - and
getting a text file showing "ajones,smith2312,mterrel2"..etc..etc..etc..
This also might be an AD excercise.
My System SpecsSystem Spec
Old 10-26-2007   #4 (permalink)
Brandon Shell [MVP]


 
 

Re: Powershell / Quest userID grab?

I just wanted to be sure I knew what you were asking for.

Effectively speaking you have the displayName and you want to find out the
sAMAccountName. Would you say that is correct?

Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject

I> Taking a list of names - "IE Jones, Amanda;Smith, John;Terrel, mike"
I> - and getting a text file showing
I> "ajones,smith2312,mterrel2"..etc..etc..etc.. This also might be an
I> AD excercise.
I>


My System SpecsSystem Spec
Old 10-26-2007   #5 (permalink)
Brandon Shell [MVP]


 
 

Re: Powershell / Quest userID grab?

Assuming you have headers in the CSV file and the colum we want is username.

Does this do it for you?
PS> import-csv c:\yourcsvfile.csv | foreach{get-qaduser -DisplayName $_.UserName
| %{$_.sAMAccountName}} | out-file youtextfile.txt -enc ASCII


Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject

BS> I just wanted to be sure I knew what you were asking for.
BS>
BS> Effectively speaking you have the displayName and you want to find
BS> out the sAMAccountName. Would you say that is correct?
BS>
BS> Brandon Shell
BS> ---------------
BS> Blog: http://www.bsonposh.com/
BS> PSH Scripts Project: www.codeplex.com/psobject
I>> Taking a list of names - "IE Jones, Amanda;Smith, John;Terrel, mike"
I>> - and getting a text file showing
I>> "ajones,smith2312,mterrel2"..etc..etc..etc.. This also might be an
I>> AD excercise.
I>>


My System SpecsSystem Spec
Old 10-26-2007   #6 (permalink)
Brandon Shell [MVP]


 
 

Re: Powershell / Quest userID grab?

This will give you both

Import-Csv c:\yourcsvfile.csv | %{$Name = $_.UserName;get-qaduser -displayName
$_.UserName| %{$_.sAMAccountName}} | %{write-output "$name : $_"}

Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject

BS> Assuming you have headers in the CSV file and the colum we want is
BS> username.
BS>
BS> Does this do it for you?
BS>
PS>> import-csv c:\yourcsvfile.csv | foreach{get-qaduser -DisplayName
PS>> $_.UserName
PS>>
BS> | %{$_.sAMAccountName}} | out-file youtextfile.txt -enc ASCII
BS>
BS> Brandon Shell
BS> ---------------
BS> Blog: http://www.bsonposh.com/
BS> PSH Scripts Project: www.codeplex.com/psobject
BS>> I just wanted to be sure I knew what you were asking for.
BS>>
BS>> Effectively speaking you have the displayName and you want to find
BS>> out the sAMAccountName. Would you say that is correct?
BS>>
BS>> Brandon Shell
BS>> ---------------
BS>> Blog: http://www.bsonposh.com/
BS>> PSH Scripts Project: www.codeplex.com/psobject
I>>> Taking a list of names - "IE Jones, Amanda;Smith, John;Terrel,
I>>> mike" - and getting a text file showing
I>>> "ajones,smith2312,mterrel2"..etc..etc..etc.. This also might be an
I>>> AD excercise.
I>>>


My System SpecsSystem Spec
Old 10-26-2007   #7 (permalink)
Ian_1


 
 

Re: Powershell / Quest userID grab?

That errors out --

PS C:\> Import-Csv c:\scripts\resp.csv | %{$Name = $_.UserName;get-qaduser
-displayName $_.UserName| %{$_.sAMAccountNam
e}} | %{write-output "$name : $_"} c:\scripts\resp.txt
ForEach-Object : Cannot bind parameter 'Process'. Cannot convert value
"c:\scripts\resp.txt" to type "System.Management
..Automation.ScriptBlock". Error: "Invalid cast from 'System.String' to
'System.Management.Automation.ScriptBlock'."
At line:1 char:120
+ Import-Csv c:\scripts\resp.csv | %{$Name = $_.UserName;get-qaduser
-displayName $_.UserName| %{$_.sAMAccountName}} |
%{ <<<< write-output "$name : $_"} c:\scripts\resp.txt

My System SpecsSystem Spec
Old 10-26-2007   #8 (permalink)
Brandon Shell [MVP]


 
 

Re: Powershell / Quest userID grab?

It looks like you are missing the "| out-file" at the end there

Try this
Import-Csv c:\yourcsvfile.csv | %{$Name = $_.UserName;get-qaduser -displayName
$_.UserName| %{$_.sAMAccountName}} | %{write-output "$name : $_"} | out-file
c:\scripts\resp.txt -enc ASCII

Also... The header information is important.

Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject

I> That errors out --
I>
I> PS C:\> Import-Csv c:\scripts\resp.csv | %{$Name =
I> $_.UserName;get-qaduser
I> -displayName $_.UserName| %{$_.sAMAccountNam
I> e}} | %{write-output "$name : $_"} c:\scripts\resp.txt
I> ForEach-Object : Cannot bind parameter 'Process'. Cannot convert
I> value
I> "c:\scripts\resp.txt" to type "System.Management
I> .Automation.ScriptBlock". Error: "Invalid cast from 'System.String'
I> to
I> 'System.Management.Automation.ScriptBlock'."
I> At line:1 char:120
I> + Import-Csv c:\scripts\resp.csv | %{$Name = $_.UserName;get-qaduser
I> -displayName $_.UserName| %{$_.sAMAccountName}} |
I> %{ <<<< write-output "$name : $_"} c:\scripts\resp.txt


My System SpecsSystem Spec
Old 10-26-2007   #9 (permalink)
Ian_1


 
 

Re: Powershell / Quest userID grab?

Well its creating the text file, but nothings in it now. Thoughts?
---Here is wheat Im running exactly:
Import-Csv c:\scripts\resp.csv | %{$Name = $_.UserName;get-qaduser
-displayName $_.UserName| %{$_.sAMAccountName}} | %{write-output "$name :
$_"} | out-file c:\scripts\resp.txt -enc ASCII

My System SpecsSystem Spec
Old 10-26-2007   #10 (permalink)
Brandon Shell [MVP]


 
 

Re: Powershell / Quest userID grab?

What happens if you remove the | out-file c:\scripts\resp.txt -enc ASCII

It should output the results to the screen

Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject

I> Well its creating the text file, but nothings in it now. Thoughts?
I> ---Here is wheat Im running exactly:
I> Import-Csv c:\scripts\resp.csv | %{$Name = $_.UserName;get-qaduser
I> -displayName $_.UserName| %{$_.sAMAccountName}} | %{write-output
I> "$name :
I> $_"} | out-file c:\scripts\resp.txt -enc ASCII


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to grab the NIC device name VB Script
Quest powershell v 1.2 PowerShell
USERID/PW Vista installation & setup
powershell memory problem agianst AD with quest (get-qaduser) PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46