Hi and good morning,
here i am again with a new question
I want to set the StartDelay to 10 seconds on multiple VM´s.
I think I have to use sometihng like
Get-VM -Name <vmname> | Set-VMStartPolicy -StartDelay 10000
But this doesn´t work...
Thx for any help
Chakoe
You are looking at the Boot Delay option, not the Startup delay.
That one lives in the VMX file and can be changed like this (value in milliseconds).
$value = "5000" $vm = Get-VM <vmname> | Get-View $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions $vmConfigSpec.BootOptions.BootDelay = $value $vm.ReconfigVM_Task($vmConfigSpec)
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Startdelay is expressed in seconds.
And you set it like this
Get-VM <vm-name> | Get-VMStartPolicy | Set-VMStartPolicy -StartDelay 10
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
your scipt returns no error, it returns an OK-Message
VM StartAction StartDelay StartOrder
-- -
-
-
vmname None 10
The VirtualCenter posts a message like:
Reconfigure AutoStart Manager Target=vmhost Status=completed
But when i check the vm ( Edit Settings, Options, BootOptions) The PowerOn Boot delay is set to 0
It seems that the script reports no error but does nothing?
Btw, you use the same logic to enable/disable the start policy on the hosts.
Get-VMHost -Name <hostname> | Get-VMHostStartPolicy | Set-VMHostStartPolicy -Enabled:$true
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are looking at the Boot Delay option, not the Startup delay.
That one lives in the VMX file and can be changed like this (value in milliseconds).
$value = "5000" $vm = Get-VM <vmname> | Get-View $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions $vmConfigSpec.BootOptions.BootDelay = $value $vm.ReconfigVM_Task($vmConfigSpec)
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey,
thanks....works fine!
Greets
Chakoe
Hi,
i stil have a little problem with this, because i cannot modify multiple vm´s...
If i change the value for the target-vm from vmname1 to vmname* (to use all vm´s beginning with "vmname" ), the script fails with the folowing error:
Method invocation failed because [http://System.Object[|http://System.Object[]] doesn't contain a method named 'ReconfigVM_Task'.
At :Row:10 Char:19
+ $vm.ReconfigVM_Task <<<< ($vmConfigSpec)
To change multiple VM's you can change Luc's script into:
$value = "5000" $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions $vmConfigSpec.BootOptions.BootDelay = $value Get-VM <vmname> | Get-View | ForEach-Object { $_.ReconfigVM_Task($vmConfigSpec) }
Regards, Robert
Is there a cmd to retrieve the current value of the bootdelay?
There is no PowerCLI cmdlet that returns that property.
But you can easily get it like this.
In PowerCLI 4.1
Get-VM | Select Name,@{N="BootDelay";E={$_.ExtensionData.Config.BootOptions.BootDelay}}
or with the New-VIProperty cmdlet
New-VIProperty -Name "BootDelay" -ObjectType VirtualMachine -Value { param($vm) $vm.ExtensionData.Config.BootOptions.BootDelay } -BasedOnExtensionProperty "Config.BootOptions" Get-VM | Select Name, "BootDelay"
When you're not yet migrated to PowerCLI 4.1, you can do
Get-VM | Select Name,@{N="BootDelay";E={($_ | Get-View).Config.BootOptions.BootDelay}}
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am trying to read the machine from a text file to but I seem to be getting synatx errors.
Any help is appreicated.
$value = "6500"
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions
$vmConfigSpec.BootOptions.BootDelay = $valueGet-Content -Path D:\abc.txt | `
ForEach-Object (Get-VM -Name $_).ReconfigVM_Task($vmConfigSpec)
}
Try it like this
$value = "6500"
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions
$vmConfigSpec.BootOptions.BootDelay = $valueGet-Content -Path D:\abc.txt | %{
(Get-VM -Name $_).Extensiondata.ReconfigVM_Task($vmConfigSpec)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks It worked!
Can you explain why ForEach-Object is not needed? And .Extensiondata is needed?
Sorry for that, the % is an alias for the Foreach-Object cmdlet.
You can check with
Get-Alias %
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference