![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
| | #9 (permalink) |
| | 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 Specs![]() |
| | #10 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||