I'm trying to Export-Csv with the following PS code but when I open the generated .csv file, all I get is: "". This has obviously something to do with the encoding and BOM I reccon, but whatever I try it wont work.
$Date = (Get-Date).AddDays(-30)
$searchroot = "Example OU"
#GetADUsers
Get-QADUser -SearchRoot $searchroot -Enabled -SizeLimit 0 | Select
UserPrincipalName,whenCreated | Where-Object {$_.CreatedDateTime -ge $Date} |
Export-Csv -Path 'ExamplePath.csv' -Delimiter ";" -Encoding UTF8
I tried adding -NoTypeInformation, removed -Delimiter, changed -Encoding. Nothing seems to be correct. If I remove Where-Object {$_.CreatedDateTime -ge $Date} it works just fine.
I might just be missing something very obvious here.
Thanks! //Victor