I am trying to create 2 variables in a function and then passing them into the second function. the 2 variables just don't seem to be being passed in. I Have tried returning the variables but doesn't seem to work either. what am I missing?
enter code here
function get-PSnames
{
$tony = 'tiny'
$tlony = 'jommy'
}
function get-PSadded ([string] $name,[string]$name2)
{
$tony + $tlony
}
get-PSnames
get-PSadded "$tony, $tlony"
Get-PSNamesfunction, unless you want to make your variables global:Get-PSNames -Name $tony -Name2 $tlony, functions run in it's own scope and not the global scope not making your variables available to anything else but, that function unless specified using a global variable:$Global:myvariable. Also, parameters are passed individually and not as a whole. Currently, you're passing$tony + $tlonyas a whole instead of individual values.