DevOps Automation: Create Google Compute Engine Instance using PowerShell Scripts
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?
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-Module GoogleCloud -Force
Step 2: Install Python
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
Import-Module GoogleCloud -Force
$env:Path += “;AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin”
Step 4: Login Credentials
gcloud auth login #web browser
Step 5: API Enable Compute Instance for Project
gcloud config set project ps-vm-create
gcloud services list –available
gcloud services enable compute.googleapis.com
Step 6: Compute Instance Create
$disk = Get-GceImage “windows-cloud” -Family “windows-2012-r2”
$config = New-GceInstanceConfig tabexp `
-MachineType n1-standard-1 `
$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.
Our Recent Posts
Developers, Sysadmins, and IT administrators have been carrying out system administration tasks or DevOps tasks ‘manually’ from time immemorial. Be it desktop machines configuration
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
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.