I am new to PowerShell and was working on a script, where I got stuck with a problem. When I Write-Host from inside a function, the variables are printed first and then the string. Otherwise it works normal, as expected.
PS C:\> function a($a,$b,$c) {
write-host "From a Function"
write-host "$a, "*", $b, "*" ,$c"
}
$a=2
$b=3
$c=4
#Calling the Function
a($a,$b,$c)
# Write-Host without function
write-host "Directly from the script"
write-host "$a, "*", $b, "*" ,$c"
- **BELOW IS THE OUTPUT**
From a Function
2 3 4, *, , * ,
Directly from the script
2, *, 3, * ,4
PS C:\>
Output should be the same, is the approach to a powershell function different while executing.