PowerShell 安装模块命令未失败但未安装模块

Ros*_*ski 7 powershell sharepoint-online powershellget

我正在尝试将 SharePoint 的 PnP 在线命令安装到我的 PowerShell 上,但是以下命令似乎不起作用;

Install-Module -name SharePointPnPPowerShellOnline -scope CurrentUser
Run Code Online (Sandbox Code Playgroud)

该命令似乎运行良好,没有出现任何错误,但是当我尝试运行应该已安装的命令时,我收到一条错误消息,指出找不到命令。

connect-pnponline : The term 'connect-pnponline' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of        
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ connect-pnponline
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (connect-pnponline:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

我查看了所有模块文件夹,但该模块不在其中任何一个中。我将我的环境路径与具有此功能的同事进行了比较,发现它们是相同的。

有谁知道可能是什么原因造成的?

Ros*_*ski 3

这是由存储在 OneDrive 上的模块引起的。默认情况下,我的模块路径设置为“%USERPROFILE%\Documents\WindowsPowerShell\Modules”,但由于我安装了 OneDrive,我的路径更改为“%USERPROFILE%\OneDrive\Documents\WindowsPowerShell\Modules”。

为了解决此问题,我转到“文档”>“Windows Powershell”>“模块”并复制了链接。然后,通过“开始”菜单,转到“编辑系统环境变量”>高级>环境变量,突出显示 PSModulePath 并单击“编辑”。进入此窗口后,我单击“新建”并粘贴我在上面找到的链接。这解决了我遇到的问题。