#PowerShell script reads CSV file comprising of VM names #Leverage 'gcloud' commands to build infra on GCP gcloud auth login acb@gmail.com #REPLACE THIS AB@GMAIL.COM WITH YOUR AUTHORIZED ACCOUNT gcloud config set project gcp_project #REPLACE THIS GCP_PROJECT1 WITH YOUR GCP PROJECT INSTANCE #define variable address to point to the uploaded CSV in the workspace $address="./vm_name_repo.csv" #define variable records to point to the CSV file records $records=Import-Csv $address #define a variable for storing VM Name $vm_name="" #run a loop till the end of the CSV records foreach ($record in $records) { $vm_name=$record.NewVMNames echo $vm_name $result=gcloud compute instances create $vm_name --zone=us-central1-a #check if the operation has been successful if(!$result) { echo "Unable to create this VM with name $vm_name" } else { echo "VM created=$vm_name" } } #remove the file from workspace Remove-Item -verbose $address