Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Create and Manage Google Compute Engine Instances Using Windows CMD and PowerShell

Google Compute Engine (GCE) is a service provided by Google Cloud Platform (GCP) that allows users to create and manage virtual machines (VMs) on Google's infrastructure. While GCE is platform-agnostic and can run various operating systems, including Windows, this article will focus on how to create and manage GCE instances using Windows CMD and PowerShell.

Prerequisites

  1. Google Cloud SDK: Ensure that the Google Cloud SDK is installed on your Windows machine. You can download it from the official Google Cloud SDK page.
  2. Google Cloud Account: You need an active Google Cloud account and a project with billing enabled.
  3. Permissions: Ensure you have the necessary permissions to create and manage GCE instances.

Step 1: Install and Configure Google Cloud SDK

First, install the Google Cloud SDK on your Windows machine:

  1. Download the installer from the Google Cloud SDK download page.
  2. Run the installer and follow the on-screen instructions.
  3. After installation, open a new CMD or PowerShell window and initialize the SDK by running:
    gcloud init
  4. Follow the prompts to authenticate and set up your default project.

Step 2: Create a GCE Instance Using CMD

You can create a new GCE instance using the gcloud command in CMD. Here’s an example of how to create a basic VM instance:

  1. Open CMD and run the following command:
    gcloud compute instances create my-windows-instance --zone=us-central1-a --machine-type=n1-standard-1 --image-family=windows-2019 --image-project=windows-cloud
    • my-windows-instance: Name of the instance.
    • us-central1-a: Zone where the instance will be created.
    • n1-standard-1: Machine type.
    • windows-2019: Image family for Windows Server 2019.
    • windows-cloud: Image project.

Step 3: Connect to Your GCE Instance Using PowerShell

After creating the instance, you can connect to it using PowerShell. You need the external IP address of the instance and the auto-generated password for the default user.

  1. Retrieve the external IP address of your instance:

    gcloud compute instances list --filter="name=my-windows-instance"
  2. Set up a password for the Windows user:

    gcloud compute reset-windows-password my-windows-instance --zone=us-central1-a --user=USERNAME

    Replace USERNAME with your desired username. This command will output the generated password.

  3. Open PowerShell and use the mstsc command to connect:

    mstsc /v:EXTERNAL_IP

    Replace EXTERNAL_IP with the IP address retrieved earlier.

Step 4: Manage Your GCE Instance Using PowerShell

You can manage your instance using various gcloud commands in PowerShell. Here are some examples:

  1. Start an Instance:

    gcloud compute instances start my-windows-instance --zone=us-central1-a
  2. Stop an Instance:

    gcloud compute instances stop my-windows-instance --zone=us-central1-a
  3. Delete an Instance:

    gcloud compute instances delete my-windows-instance --zone=us-central1-a

Conclusion

Managing Google Compute Engine instances from a Windows environment is straightforward with the Google Cloud SDK and the gcloud command-line tool. By following the steps outlined above, you can easily create, connect to, and manage your GCE instances using CMD and PowerShell.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.