I want to keep the output of this command on the same line:
((Get-ADUser -filter {employeetype -eq "Employee"}).SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object {$_.Name,$_.Department,$_mail}
Currently the output shows up like this:
James Roberts
Accounting
[email protected]
But, I need to have it show up like:
James Roberts Accounting [email protected]
I've also tried using (based on a suggestion I found):
((Get-ADUser -filter {employeetype -eq "Employee"}).SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object {$_.Name;$_.Department;$_mail}
but, I get the same three lines of output and not one line.
Foreach-Objectyou should useSelect-Object -Property-joinwith whatever delimiter you want. [grin] take a look atGet-Help about_Joinfor some useful examples.