VMware Cloud Community
athurston
Enthusiast
Enthusiast
Jump to solution

Add multiple vms to a running script

Hi All,

This script below works fine

$vmtest = Get-vm "vmname" | get-view

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec.changeTrackingEnabled = $true

$vmtest.reconfigVM($vmConfigSpec)

how can i pass a list of virtual machines in a text file c:\vms.txt to this script?

Thanks

Alex

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I assume your TXT file has a vmname on each line, then you could do something like this

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.changeTrackingEnabled = $true

Get-Content c:\vms.txt | %{
 
$vmtest = Get-vm -Name $_
 
$vmtest.ExtensionData.ReconfigVM($vmConfigSpec)
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

I assume your TXT file has a vmname on each line, then you could do something like this

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.changeTrackingEnabled = $true

Get-Content c:\vms.txt | %{
 
$vmtest = Get-vm -Name $_
 
$vmtest.ExtensionData.ReconfigVM($vmConfigSpec)
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
athurston
Enthusiast
Enthusiast
Jump to solution

Thanks again Smiley Happy

Reply
0 Kudos