directly write to the console is the same as out-host.
write-host does a tostring() on the objects for displaying forcing the
object to string format, but can be used for collored output.
but we aware that write-host sometimes can give a other output as expected :
some samples that might help.
PS C:\Users\mvanorsouw> $a = 1,2,3
PS C:\Users\mvanorsouw> write-host $a
1 2 3
PS C:\Users\mvanorsouw> out-host $a
Out-Host : A positional parameter cannot be found that accepts argument
'System.Object[]'.
At line:1 char:9
+ out-host <<<< $a
PS C:\Users\mvanorsouw> out-host -InputObject $a
1
2
3
PS C:\Users\mvanorsouw> $a | write-host -ForegroundColor yellow
1
2
3
(I wonder whether I can cal the error a bug)
Greetings /\/\o\/\/
http://thePowerShellGuy.com
"how to display variable value?" <how to display variable
value?@discussions.microsoft.com> wrote in message
news:6AF2A622-5CCA-4C9D-AC51-D1ECA99E4131@xxxxxx
> Suppose I have a variable initialized like
>
> $abc = kapil
>
> then what is the difference between
>
> write-host $abc
>
> and
>
> directly writing $abc on console