You can use the return keyword in PowerShell to return values from a PowerShell function. Here is a quick example for your reference –
1 2 3 4 5 6 7 8 |
## Create a new dummy function that adds two numbers function myfun { $sum = 5 + 15 return $sum } ## Execute the function Write-Host $(myfun) ## returns 20 |