I am having trouble modifying an existing script to run from a text list instead of the Powershell VM extension command 'get-vm.'
The script I found is this:
$spec = new-object VMware.Vim.VirtualMachineConfigSpec
$spec.tools = New-Object VMware.Vim.ToolsConfigInfo
$spec.tools.syncTimeWithHost = $false
$vms=get-vm $vm |?{$_.extensiondata.config.tools.synctimewithhost -like $true}
$vms|select -expand name
$vms|%{$_.extensiondata.reconfigvm_task($spec)}
I understand most of what the script is doing. I'm not sure about the select -expand name line though.
I tried this:
forEach ($vminget-contentC:\scripts\servers.txt)
{$_.extensiondata.reconfigvm_task($spec)}
But it doesn't work. Tried a pipe too...
$vm | {$_.extensiondata.reconfigvm_task($spec)} of course this doesn't work either.
Any help appreciated.