Function
Create a function and return the value
function CombineString () {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)] $stringIn1,
[Parameter(Mandatory = $true)] $stringIn2
)
$newStr = $stringIn1 + " " + $stringIn2
# To return the value, simply print it
$newStr
}
$theNewString = CombineString -stringIn1 "Hello" -stringIn2 "World"
Write-Host "The new string is $theNewString"
No Comments