BlogDevOps

DevOps Automation: Create Google Compute Engine Instance using PowerShell Scripts

By April 23, 2020 August 7th, 2020 No Comments

DevOps Automation: Create Google Compute Engine Instance using PowerShell Scripts

Devops

In this post, learn how to automate creation of VM instances using DevOps with PowerShell scripts.

Google Compute Engine (GCE) is undoubtedly one of the best and most widely used public Infrastructure-as-a-Service (IaaS) platforms for creating customizable virtual machines. The GCE allows software developers to create and run virtual machines instances on Google’s physical hardware (infrastructure) for development, testing, and deployment, operations of applications.

You must have googled for a lot of resources and information on how to create a VM instance on Google Cloud Platform (GCP) and must have also been successful. But that’s all a manual and time-consuming job! Why waste so much time and efforts for manual tasks when you can leverage DevOps?

Related Post: Automate Creation of Windows AWS EC2 instance using DevOps

When it comes to DevOps and automation, every cloud workload and operation can be automated which will save your company several business hours, hundreds of dollars, IT administration resources, and efforts. There is no such cloud management task which cannot be automated with DevOps, and especially when you’re with us.

So, below is a step-by-step guide with PowerShell Scripts on how to automate compute engine VM instance creation on Google Cloud (gCloud) Platform:

Step 1: Install Google Cloud Module
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module GoogleCloud -Force
Step 2: Install Python
[Net.ServicePointManager]::SecurityProtocol =
[Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri “https://www.python.org/ftp/python/3.7.0/python-
3.7.0.exe” -OutFile “appdata/python-3.7.0.exe”
appdata/python-3.7.0.exe /quiet InstallAllUsers=0 PrependPath=1 Include_test=0
Step 3: Install SDK
$env:GCLOUD_SDK_INSTALLATION_NO_PROMPT = $true
Import-Module GoogleCloud -Force
$env:Path += “;AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin”
Step 4: Login Credentials
gcloud auth activate-service-account –key-
file=C:\Users\Administrator\Downloads\migration-dev-260106-97804e2bbc01.json
gcloud auth login #web browser
Step 5: API Enable Compute Instance for Project
gcloud projects list
gcloud config set project ps-vm-create
gcloud services list –available
gcloud services enable compute.googleapis.com
gcloud info
Step 6: Compute Instance Create
gcloud compute images list –project windows-cloud –no-standard-images
$disk = Get-GceImage “windows-cloud” -Family “windows-2012-r2”
$config = New-GceInstanceConfig tabexp `
-MachineType n1-standard-1 `
-DiskImage $disk
$config | Add-GceInstance -Project ps-vm-creategcloud compute reset-windows-password tabexp –quiet
And our automation is complete! How easy was that?

With extensive experience in Azure cloud migration services, DevOps consulting and automation services, TabExp Apps and it’s team of skilled cloud consultants have helped several companies across India and UK in automating manual cloud operations and thereby reducing significant IT costs.

Get in touch with us for advanced DevOps consulting services to drive the pace of software development.

Our Recent Posts

Devops Automation

Developers, Sysadmins, and IT administrators have been carrying out system administration tasks or DevOps tasks ‘manually’ from time immemorial. Be it desktop machines configuration

Database Backup & Restore

Microsoft SQL is the most widely used database management system. As a user, you put huge amount of data there. Using this popular database is easy but its maintenance

Automate Remote Machine login

When developers are working on several remote machines via their local user machine, frequent and regular logins to the virtual machines (VMs) are tedious and time-consuming.

Leave a Reply