我在 Visual Studio Code 中制作了一个使用 command 的 PowerShell 脚本,Get-PSDrive
令我惊讶的是,在使用 VS Code 时,似乎出现了一个与我的C:\
驱动器相同的新驱动器Temp
。
据我所知,这个结果让我大吃一惊,除了我的主C:\
驱动器外,我只连接了 2 个其他驱动器。我试图在其他终端上复制它但没有成功,除了 PowerShell 7:
当我看到它被 PwSh 7 复制时,我决定使用$host
变量检查每个 PowerShell 的版本,我看到了更意想不到的东西:
Version : 5.1.19041.1
Windows 终端 PowerShell 5.1
Version : 5.1.19041.1
PowerShell 5.1
Version : 5.1.19041.1
PowerShell 5.1 (86x)
Version : 7.0.2
PowerShell 7 (86x)
Version : 7.0.2
Windows 终端 PowerShell 7
这一切看起来都很正常,但是当我检查 VSCode 时$host
,我得到了结果
Version : 2020.6.0
是什么导致输出的差异
Get-PSDrive | Where-Object {$_.Provider.Name -eq "FileSystem"}
在 PwSh 7、PowerShell 5.1 和 VS Code PwSh 之间?