Variables in modules in PowerShell Variables in modules in PowerShell powershell powershell

Variables in modules in PowerShell


Function SetSQLServerAddr ([string] $name){    $SQLServer = $name}

That creates a new local $SQLServer in the scope of that function.

If you want to update a variable at module (.psm1) scope then you need to prefix the name to indicate that:

Function SetSQLServerAddr ([string] $name){    $script:SQLServer = $name}

For more on scopes see get-help about_scopes.