首页 文章

为什么PowerShell无法找到gcloud cmdlet?

提问于
浏览
21

我已经更新了Google Cloud 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:术语“Get-GcsBucket”未被识别为cmdlet,函数,脚本文件或可操作程序的名称 . 检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试 .

如何让PowerShell识别gcloud cmdlet?

1 回答

  • 24

    不幸的是,只有在安装了Google Cloud SDK时才会对PowerShell提供cmdlet所需的PSModulePath修改 - 而不是刚刚更新时 .

    对大多数人来说,最简单的解决方法是卸载并重新安装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 .

相关问题