2016-08-22 112 views
20

我已經更新了谷歌雲SDK(gcloud),無論是在一般使用:爲什麼PowerShell無法找到gcloud cmdlet?

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?

回答

23

不幸的是,只有在安裝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。

相關問題