hey all,
this isnt strictly a powercli question, but hopefully someone can provide some insight into this.
I am building some pretty chunky scripts to do stuff and want to use functions where i can, as you do
problem is any variables i create/update during the execution of the function are not available outside of the function on PS 1 does anyone know how to do this?
think of the code like this:
function blah
{
Write-Host "yea do some stuff"
$var = 1 + 1
}
$var is only accessible inside the function...i guess by design, but the code blocks i am trying to build need to be able to spit out a $var - am i missing some fundamental part of functions?
hopefully someone can push me in the right direction - thanks in advance for the help!
Regards,
David
You can let the function return the variable to your main like this
function blah { Write-Host "yea do some stuff" $var = 1 + 1 $var } $mainvar = blah
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can let the function return the variable to your main like this
function blah { Write-Host "yea do some stuff" $var = 1 + 1 $var } $mainvar = blah
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
many thanks!