I have this line of code that gets me all the AD users from my Active Directory server but when I look the CSV file it generates (open with Excel) then the file is not formatted properly.
Get-ADUser -Filter * -SearchBase "DC=mydomainname, dc=local" |
Select-Object name, samaccountname |
Export-Csv -path "\\mypcname\c$\ADusers.csv" -NoTypeInformation -Encoding UTF8
I expected the output to be like:
Column1 Column2 Jon Doe JDoe
And it is:
name,"samaccountname" Guest,"Guest"
all in one column.
Edit:
Requested screenshot: