Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't PowerShell find the gcloud cmdlets?

Tags:

I've updated the Google Cloud SDK (gcloud), both in general with:

gcloud components update 

And just for PowerShell with:

gcloud components update powershell 

Running gcloud --version shows:

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 

When I open PowerShell and try Get-GcsBucket though, I see this error:

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.

How can I get PowerShell to recognize the gcloud cmdlets?

like image 408
Jon Skeet Avatar asked Aug 22 '16 16:08

Jon Skeet


People also ask

How do you check gcloud is installed or not?

The first thing to do after successful installation is open your command line and type “gcloud” to check whether Cloud SDK has installed perfectly. Run “gcloud init”, it opens up a new browser window and asks to login into your google cloud account.

How do I access gcloud config?

Configurations are stored in your user config directory (typically ~/. config/gcloud on MacOS and Linux, or %APPDATA%\gcloud on Windows); you can find the location of your config directory by running gcloud info --format='value(config.

How do I install cloud tools?

In your browser, log in to your Google user account when prompted and click Allow to grant permission to access Google Cloud Platform resources. At the command prompt, select a Cloud Platform project from the list of those where you have Owner, Editor or Viewer permissions.


1 Answers

The simplest fix for most people will be to uninstall and reinstall the Google Cloud SDK. This doesn't lose any configuration information, so you don't need to run gcloud init or gcloud auth afterwards.

As an alternative, you can run the command that the installer would normally run. Find your Google Cloud SDK installation directory (e.g. %AppData%\..\Local\Google\Cloud SDK or %ProgramFiles(x86)%\Google\Cloud SDK). Within that directory, find google-cloud-sdk\platform\GoogleCloudPowerShell. In there, there's a script called AppendPsModulePath.ps1. Run that, and it will modify the PSModulePath environment variable for your current user. From then on, new PowerShell windows will have the cmdlets available.

like image 122
Jon Skeet Avatar answered Sep 25 '22 12:09

Jon Skeet