'gcloud compute ssh port forwarding in powershell

I would like to use gcloud compute ssh with portforwarding options in windows. When I executed following command in "Google Cloud SDK Shell" shortcut on desktop, it worked.

Welcome to the Google Cloud CLI! Run "gcloud -h" to get the list of available commands.
---

C:\Program Files (x86)\Google\Cloud SDK>gcloud compute ssh instance-name --tunnel-through-iap -- -L xxxx:localhost:vvvv
C:\Program Files (x86)\Google\Cloud SDK>

But when I executed same command in powershell, it failed.

PS C:\Users\xxxx> gcloud compute ssh instance-name --tunnel-through-iap -- -L  xxxx:localhost:vvvv
ERROR: (gcloud.compute.ssh) unrecognized arguments:
  -L
  xxxx:localhost:vvvv
  To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS

How can I pass SSH args to gcloud command in powershell? I could not use past command history in "Google Cloud SDK Shell" shortcut, so I would like to use powershell (in which I can use past command history). Thanks.



Solution 1:[1]

I should quote 2 dashes as '--' when I execute commands in powershell. Following command works in powershell according to link.

gcloud compute ssh instance-name --tunnel-through-iap '--' -L  xxxx:localhost:vvvv

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ryamy