Write-Output gotcha


 
warns of unexpected output from
 
function convert-dollar2euro($amount, $rate=0.8) {
write-output $amount * $rate
}
 
that needs rewritten as
 
function convert-dollar2euro($amount, $rate=0.8) {
write-output ($amount * $rate)
}
 
or perhaps
 
function convert-dollar2euro($amount, $rate=0.8) {
$convertedamount = $amount * $rate
write-output $convertedamount
}
 
or even
 
function convert-dollar2euro($amount, $rate=0.8) {
$amount * $rate
}
 
 



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file