In one of my script I have the following problem: assigning to a string variable the result of a function makes the string an array. Example:
---------- (function edited for clarity)
$x=""
Function extrMail{param([string]$pFullAddr)
[string]$wAddr = ""
$regex = ".. omitted for brevity, check for valid mail address..."
$pFullAddr -match $regex | Out-Null
$wAddr = $Matches.values
if ($wAddr -notlike "@") {
$wAddr = "[email protected]"
}
return [string]$wAddr
}
... $x= extrMail "xy"
----------
but if I look at it it's
$x=1 abcd $x.Count # is 2
I've made several runs, in step mode to try and find where the problem arise, but no way...
I can't understand why...
Thanks for any help
PS: I'm a seasoned system engineer, I know various programming languages but I'm really a newbie with Powershell...