powershell - 为什么 PowerShell 找不到 gcloud cmdlet?

标签 powershell google-cloud-sdk

我已经更新了谷歌云 SDK (gcloud),一般都包含:

gcloud components update

仅适用于具有以下功能的 PowerShell:
gcloud components update powershell

运行 gcloud --version显示:
Google Cloud SDK 122.0.0
beta 2016.01.12
bq 2.0.24
bq-win 2.0.24
bundled-python 2.7.10
core 2016.08.16
core-win 2016.08.05
gcloud
gsutil 4.20
gsutil-win 4.20
powershell 0.1.3
windows-ssh-tools 2016.05.13

当我打开 PowerShell 并尝试时 Get-GcsBucket不过,我看到了这个错误:

Get-GcsBucket : The term 'Get-GcsBucket' 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.



如何让 PowerShell 识别 gcloud cmdlet?

最佳答案

不幸的是 PSModulePath 使 cmdlet 可用于 PowerShell 所需的修改仅在安装 Google Cloud SDK 时发生,而不是在刚更新时发生。

对于大多数人来说,最简单的解决方法是卸载并重新安装 Google Cloud SDK。这不会丢失任何配置信息,因此您无需运行 gcloud initgcloud auth然后。

作为替代方法,您可以运行安装程序通常会运行的命令。找到您的 Google Cloud SDK 安装目录(例如 %AppData%\..\Local\Google\Cloud SDK%ProgramFiles(x86)%\Google\Cloud SDK)。在该目录中,找到 google-cloud-sdk\platform\GoogleCloudPowerShell .在那里,有一个名为 AppendPsModulePath.ps1 的脚本。 .运行它,它将修改 PSModulePath当前用户的环境变量。从那时起,新的 PowerShell 窗口将提供可用的 cmdlet。

关于powershell - 为什么 PowerShell 找不到 gcloud cmdlet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39084838/

相关文章:

powershell - 使用Microsoft Graph API将文件上传到SharePoint Online

python - 没有名为 appengine.api 的模块

google-cloud-platform - gcloud auth 登录抛出错误 : gcloud crashed (ConnectionError): HTTPSConnectionPool(host ='oauth2.googleapis.com' , 端口 = 443):超过最大重试次数

PowerShell:引用带有空格的属性

Powershell Start-Process -NoNewWindow 不能与 -Credentials 一起使用

powershell - 如果禁止使用标准位置,则将PowerShell配置文件脚本放在哪里?