Reputation: 2630
$output=$(dir)
Write-Host $output
The output I have is:
jboss-eap-5.1 jboss-eap-6.1 jboss-eap-6.1(2) Middleware Oracle TestSymlinksJboss TomcatA TomcatB Was7.0
Is there any way to have the normal output like this: echo $output
Directory: C:\Servers
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 9/18/2012 10:33 AM jboss-eap-5.1
d---- 5/9/2013 1:10 PM jboss-eap-6.1
d---- 8/22/2013 11:33 AM jboss-eap-6.1(2)
d---- 1/22/2013 2:29 PM Middleware
d---- 1/22/2013 2:25 PM Oracle
d---- 8/1/2013 2:43 PM TestSymlinksJboss
d---- 4/4/2013 4:25 PM TomcatA
d---- 7/22/2013 4:49 PM TomcatB
d---- 10/18/2012 3:00 PM Was7.0
I use Write-Host inside a function (so I don't want to use echo ) Thanks for any reply
Upvotes: 1
Views: 1486
Reputation: 201692
Write-Host host does no formatting. It just displays the strings (or objects by coercing them to string) that you provide. Try this to get PowerShell to do some formatting for you:
Write-Host ($output | Out-String)
Upvotes: 7