I am not understanding this. If I put the param at the top of my script then run the script with command line and specify a user name, the user name is assigned to $UserName
Param([string]$UserName)
If I wrap it in a function then run it from command line:
E.g: ./Script.ps1 -UserName BLAH
It's not being assigned to $UserName
Function MainFunction
{
Param([string]$UserName)
}
#Call Mainfunction
MainFunction;
Why is that?