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!
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 ]