Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

By placing a loop around the previous code.

Something like this


Get-VM | Get-View | %{
  $spec = new-object VMware.Vim.VirtualMachineConfigSpec
  foreach($dev in $_.Config.Hardware.Device){
    if($dev.DeviceInfo.Label -like "Serial Port*"){
	  $temp = New-Object VMware.Vim.VirtualDeviceConfigSpec
	  $temp.device = [http://VMware.Vim.VirtualDevice|http://VMware.Vim.VirtualDevice]$dev
	  $temp.device.connectable.connected = $false
	  $temp.device.connectable.StartConnected = $false
	  $temp.operation = "edit"
	  $spec.deviceChange += $temp
    }
  }
  $_.ReconfigVM_Task($spec)
  Remove-Variable $spec
}


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

Reply
0 Kudos