Export-CSV comes out empty

Pagina: 1
Acties:
  • 111 views

Acties:
  • 0 Henk 'm!

  • Number5639
  • Registratie: September 2020
  • Laatst online: 11-09-2020
I Want to import a list of users and then i want select only the usernames. After that i want to export the usernames to a .CSV or .txt file

I try to run the following code but unfortunately the CSV or TXT file it comes out empty.

My Script:


#Variable

$Users = get-content "C:\Temp\Project\saxousers.txt"

#Convert Display Name to SamAccountName

Foreach ($User in $Users) {

Get-ADUser -filter { DisplayName -eq $User} | Select samAccountName | export-csv "c:\temp\project\NameToSamAccountName.txt"}

When I run the code without exporting it, I do can see the output in Powershell.

Am i missing a PIPE somewhere?


Many thanks ahead!

[ Voor 6% gewijzigd door Number5639 op 11-09-2020 11:43 ]


Acties:
  • 0 Henk 'm!

  • Bolletje
  • Registratie: Juni 2008
  • Laatst online: 18-09 20:24

Bolletje

Moderator Harde Waren
Hi, the language on this forum is typically Dutch. Also we request from our users to be a bit more detailed in their problem description. Lastly, it seems you have more a of coding problem which does not have anything to do with hardware / laptops. Due to the reasons listed above, I'm closing the topic.

Please see our software / coding section at Softwareontwikkeling

Dit topic is gesloten.