gpt4 book ai didi

powershell - 安装 PowerShellGet 模块

转载 作者:行者123 更新时间:2023-12-02 22:49:00 24 4
gpt4 key购买 nike

我正在使用 Windows 2012 R2,它运行的是 PowerShell 4.0 版。我已经升级到 5.0 版。

似乎当我执行基本命令时出现错误,例如,

PS C:\Windows\system32> Install-Module –Name PowerShellGet –Force –Verbose

Install-Module : The 'Install-Module' command was found in the module 'PowerShellGet', but the module could not be loaded. For more information, run 'Import-Module PowerShellGet'. At line:1 char:1 + Install-Module –Name PowerShellGet –Force –Verbose + ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule



另一个例子:
PS C:\Windows\system32> import-module PowerShellGet

Get-Variable : The term 'Get-Variable' 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 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.3.2\PSModule.psm1:18 char:28 + $script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction ... + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-Variable:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException



我基本上遵循此处找到的 PowerShellGet 的安装方法: https://docs.microsoft.com/en-us/powershell/gallery/psget/get_psget_module

我被困在本指南中的“安装模块”命令中。

最佳答案

在执行 install-module 之前在 powershell 上执行命令:'Set-ExecutionPolicy Unrestricted'。
(受限模式可帮助您防止未经授权的脚本)

关于powershell - 安装 PowerShellGet 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46226429/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com