Powershell called a Powershell script

How is the behavior different from & powershell .\other.ps1 and & .\other.ps1 ?

Edit: In particular, how do they differ if there is an error in other.ps1 ?

+6
source share
1 answer

In the first case, you get another PowerShell process, and the script cannot read the variables defined in the current session:

 PS> $foo = 'bar' PS> 'Write-Host $foo'|Set-Content x.ps1 PS> & powershell .\x.ps1 PS> & .\x.ps1 bar 
+12
source

Source: https://habr.com/ru/post/920030/


All Articles