Get different results in new powershell process and active process

Copper Contributor

I execute the following code in a new powershell process, get the results

"chrome IE"

Continue run the same code in the active powershell process get the results with new line

"chrome

IE"

I think this may be related with the type issues. But I still don't know why the same code results is different in new powershell process and active powershell process.

 

Param(
[string]$Browsers = "Chrome,IE"
)

$browsers = $Browsers.split(",")

foreach ($browser in $browsers) {
$browser
}

Capture.PNG

1 Reply

The Param() statement should only be used within a function definition, not directly. Other than that, check if something isn't modifying the $Browsers variable, and make sure you are always using it in the correct scope.