Assigning (multiple) return values with Write-Output works well, but you should keep in mind that Write-Output is picky and returns the exact thing you specified. So, if you want to return a calculated result, you should make sure it is put in parenthesis:
Function Convert-Dollar2EuroA($amount, $rate=0.8) {
$amount * $rate
}
Function Convert-Dollar2EuroB($amount, $rate=0.8) {
Write-Output $amount * $rate
}
Function Convert-Dollar2EuroC($amount, $rate=0.8) {
Write-Output ($amount * $rate)
}
Note the differences:
Convert-Dollar2EuroA 100
80
Convert-Dollar2EuroB 100
100
*
0,8
Convert-Dollar2EuroC 100
80
$amount * $rate
}
Function Convert-Dollar2EuroB($amount, $rate=0.8) {
Write-Output $amount * $rate
}
Function Convert-Dollar2EuroC($amount, $rate=0.8) {
Write-Output ($amount * $rate)
}
Note the differences:
Convert-Dollar2EuroA 100
80
Convert-Dollar2EuroB 100
100
*
0,8
Convert-Dollar2EuroC 100
80