Using PowerShell to manage GCP resources

From PUBLIC-WIKI
Revision as of 13:50, 12 March 2019 by Eyales (talk | contribs) (Created page with "== How to configure PowerShell for managing GCP resources (Windows platform) == * Login to the machine using privileged account. * From command prompt, run the command below t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

How to configure PowerShell for managing GCP resources (Windows platform)

  • Login to the machine using privileged account.
  • From command prompt, run the command below to invoke PowerShell:
powershell
Note: You need to run cmd.exe or PowerShell.exe as administrator.
  • Run the command below to find out the current PowerShell version:
$PSVersionTable.PSVersion
  • In-case you currently have version older than 5.1, follow the article below to locate the download URL for upgrading to the latest version of PowerShell:
https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell?view=powershell-6
Also, review the article below for PowerShell installation pre-requirements:
https://docs.microsoft.com/en-us/powershell/scripting/setup/windows-powershell-system-requirements?view=powershell-5.1
  • Run the below command to check if you have PowerShellGet installed on your system:
Get-Module PowerShellGet -list | Select-Object Name,Version,Path
  • In-case you don’t have PowerShellGet, run the commands below:
Install-PackageProvider Nuget –Force
Install-Module -Name PowerShellGet –Force
For more information about installation or upgrade of PowerShellGet, see:
https://docs.microsoft.com/en-us/powershell/gallery/installing-psget
  • Exit PowerShell console and command prompt.
  • Install Google Cloud SDK, as instructed below:
https://cloud.google.com/sdk/docs/quickstart-windows
  • Run the following from command prompt to initialize the Cloud SDK:
gcloud init --console-only
  • Select a GCP project from the list
  • Select a default Compute region and zone