Reputation: 137722
How does the behaviour differ between & powershell .\other.ps1
and & .\other.ps1
?
Edit: In particular, how do they differ if there's an error in other.ps1
?
Upvotes: 6
Views: 810
Reputation: 354774
You get another PowerShell process in the former case and the script cannot read variables defined in your current session:
PS> $foo = 'bar'
PS> 'Write-Host $foo'|Set-Content x.ps1
PS> & powershell .\x.ps1
PS> & .\x.ps1
bar
Upvotes: 12