Is there any Get-GCE* PowerShell command that will do the same as "gcloud compute networks subnets list"? I have installed the latest Google Cloud SDK and PowerShell cmdlet's.
Asked
Active
Viewed 234 times
2 Answers
0
Yes,Check the Quick Star on how to enable Cloud Tools for PowerShell, authenticate with the Cloud SDK.
After, as described Here you can run
PS C:\> Get-GceNetwork
Syntax
Get-GceNetwork
[-Project <String>]
[-Name] <String[]>
[<CommonParameters>]
Here is list of Cloud Tools for PowerShell of cmdlets that lets you manage Google Cloud Platform resources.

Alioua
- 411
- 2
- 8
-
Thanks. However IPv4Range always seems to be null. Is there away to expand the links for the subnets into redable objects? (Get-GceNetwork).Subnetworks – Christoffer Andersson Jan 07 '19 at 05:43
-1
The Powershell cmdlets do not seem to provide this data.
My approach has been to use the gcloud command line tool with JSON output. Powershell can digest this easily so there is no additional parsing required. I have had to do this for both projects and networks.
foreach($p in (gcloud projects list --format=json --quiet| ConvertFrom-Json))
{
foreach($n in (gcloud compute networks subnets list --format=json --quiet --project $p.projectId | ConvertFrom-Json))
{
}
}

user594102
- 1
- 1
-
Hello and welcome to stack exchange. You could make this answer better with a little explanation of that code - what it does, why it solves the problem. – Danny Staple Oct 03 '20 at 12:29