Let's say I have a function that takes parameters, which all well-written ones should.  And they have intelligent defaults, again as well-written ones should.  The outer script exposes those parameters via the outer param() statement, but how do I pass them into the script? 

 

param ($foo = $null);

function Test-It {
    param ($foo = $( if ($script:$foo) { $script:foo; } else { 'bar'; }));

    "`$foo is $foo";
}

 

This way, the function gets to set the default, but defaults to the value in the outer script, if it's set.