Forum Discussion

Pradeep MISHRA's avatar
Pradeep MISHRA
Copper Contributor
Jun 13, 2020

Start VM using CSV input

Hi Support,

I am trying to creating power shell script to start & stop VM with import csv parameter but its showing failed.

Example: Resource Group name and VMName maintain in CSV.

 

 

 

Import-csv "D:\Az_Powershell_13_06_20\startvm.csv" 
Start-AzureRmVM -ResourceGroupName $"AzureResourceGroup" -Name $"VMNAME"

 

 

 

  • Try something like this:

     

    Import-csv "D:\Az_Powershell_13_06_20\startvm.csv" | % { Start-AzureRmVM -ResourceGroupName $_.AzureResourceGroup -Name $_.VMNAME }
  • Try something like this:

     

    Import-csv "D:\Az_Powershell_13_06_20\startvm.csv" | % { Start-AzureRmVM -ResourceGroupName $_.AzureResourceGroup -Name $_.VMNAME }

Resources