I have the following script, it's a one liner but still a script, that it's working but giving me undesired spaces.
Get-ADUser -Server ServerName -Filter * -Properties whenCreated | Where-Object {$_.whenCreated -ge ((Get-Date).AddHours(-24)).Date} |Select-Object Name |Format-Table -HideTableHeaders |Out-File C:\Scripts\NewUserList.txt
The result would be some like this
abc123
xyz321
nmo321
Noticed that there are a lot of spaces after the user name. When I feed this file to another script, it fails because it's looking for the username with the spaces in them.
How can I remove the spaces in my result?
Thanks.