In addition to Alistair's answer about the conversion, the string returned by Read-Host to int , you can use the Math library to round the value.
Code example
function Get-Square([int] $value) { $result = [Math]::Pow($value,2) return $result } $value = Read-Host 'Enter a value' $result = Get-Square $value Write-Output "$value * $value = $result"
results
Enter value: 4
4 * 4 = 16
source share