1

I am creating GCP VMs using a combination of the "New-GceInstanceConfig" and "Add-GceInstance", and it is working fine. However, I would like to add in the ability to turn on the virtual display. I can do this in the Console, however I need to turn the VM off, enable the setting, then turn the VM back on, which is tedious. I would like to be able to do this in powershell at VM create time, however I cannot see to find anything in the docs on how to do this. I am looking at the docs here.

I have found several docs that explain how to do this in the Console, using REST, or gcloud. I just can't seem to find a way to do it with Powershell?

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Mike
  • 93
  • 1
  • 1
  • 6
  • I have looked at the doc that you linked, and that is helpful - I have been able to add the enable display with the methods documented there. However, that does not help in the Powershell case. I am running in an elevated Powershell window, and am able to create VMs with no problem, it is just the display option that I am struggling with. – Mike May 27 '21 at 12:29
  • I have tried adding the --enable-display-device flag to my Powershell commands with no luck. If I add --enable-display-device to the existing New-GceInstanceConfig command, I get an immediate error at run time: System.Management.Automation.ParameterBindingException: A positional parameter cannot be found that accepts argument '--enable-display-device'. If I add --enable-display-device to the existing Add-GceInstance command, the command runs and says it created a VM, however if I look in the portal the VM was not created. – Mike May 27 '21 at 12:30
  • Hey @Mike, have you installed the [required component](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display#install_driver) for PowerShell too? – Farid Shumbar Jun 01 '21 at 10:31

2 Answers2

1

I ended up switching the code over to using the gcloud commands to create the VM instead of the powershell commands and got it working just fine.

Mike
  • 93
  • 1
  • 1
  • 6
0

You can refer to the gcloud section of the document to enable the virtual display.

gcloud commands like gcloud compute instances create [INSTANCE_NAME] --enable-display-device work in PowerShell too. You also need to run PowerShell as an admin.

Farid Shumbar
  • 1,360
  • 3
  • 10