Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
& powershell .\other.ps1和之间的行为有何不同& .\other.ps1?
& powershell .\other.ps1
& .\other.ps1
编辑:特别是,如果出现错误,它们有何不同other.ps1?
other.ps1
在前一种情况下,您将获得另一个 PowerShell 进程,并且脚本无法读取当前会话中定义的变量:
PS> $foo = 'bar' PS> 'Write-Host $foo'|Set-Content x.ps1 PS> & powershell .\x.ps1 PS> & .\x.ps1 bar