Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从Visual Studio/Code运行时,PowerShell不会加载所有PSModulePath_C#_Visual Studio_Powershell - Fatal编程技术网

C# 从Visual Studio/Code运行时,PowerShell不会加载所有PSModulePath

C# 从Visual Studio/Code运行时,PowerShell不会加载所有PSModulePath,c#,visual-studio,powershell,C#,Visual Studio,Powershell,正如您可以从中看到的,由于某种原因,当我在Visual Studio中通过调用或启动新的PowerShell进程从代码运行PowerShell时,它并不包括手动启动Windows PowerShell命令提示符时包含的所有内容 如果我执行(获取项目Env:\PSModulePath).Value-Split';'在常规Windows PowerShell命令提示符下,我得到以下7条路径: C:\Users\Dan Schroeder\Documents\WindowsPowerShell\Mod

正如您可以从中看到的,由于某种原因,当我在Visual Studio中通过调用或启动新的PowerShell进程从代码运行PowerShell时,它并不包括手动启动Windows PowerShell命令提示符时包含的所有内容

如果我执行
(获取项目Env:\PSModulePath).Value-Split';'在常规Windows PowerShell命令提示符下,我得到以下7条路径:

C:\Users\Dan Schroeder\Documents\WindowsPowerShell\Modules\
C:\Program Files(x86)\PowerShell社区扩展\Pscx3\
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
C:\ProgramFiles(x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\
C:\Program Files\Microsoft安全客户端\MpProvider\
C:\ProgramFiles(x86)\\Code Owls LLC
但是,如果从代码运行它,则会得到以下3条路径:

C:\Users\Dan Schroeder\Documents\WindowsPowerShell\Modules\
C:\Users\Dan Schroeder\Documents\WindowsPowershell\Modules
C:\Program Files(x86)\Code Owls LLC\StudioShell\bin\\\\\\\\。。

为什么它们如此不同?因为当我从代码运行时,它不包括
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
,很多默认的内置cmdlet都不可用(例如
获取日期
测试路径
,等等)。

我找到了问题的原因,它隐藏在我的问题中。我卸载了(Visual Studio PowerShell扩展),现在一切正常。看起来这个扩展中有一个bug

在我的问题中,您可以看到它是我从VisualStudio运行时列出的最后一个PSModulePath,它有一个相对路径,其中其余部分有一个绝对路径


我将为StudioShell打开一个新的bug以修复此问题。

我已在上为此问题创建了一个bug