Reputation: 3524
I have a strange problem, i have a very simple function.
This is my powershell code
$exclude = @()
function GetOracleDb {
param([string]$servername)
$exclude += $servername
}
GetOracleDb "Myserver2"
$exclude
Why my $exclude array is empty?
Thanks for your help
Upvotes: 2
Views: 2143
Reputation: 60918
change it like this:
$global:exclude += $servername
The scope of $exclude inside a function is different from this one outside.
Upvotes: 6