How to set VM guest settings with VIPowershell
By exemple I would like to set the "VM Properties/ options / Check and upgrade tools before each power-on" ?
Best regards
Hi ykalchev,
I have setup the new Beta1.
I have an error message when created VirtualmachineConfigSpec object... any idea ?
see bellow
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> $vmConfigSpec = N
ew-Object VMware.Vim.VirtualMachineConfigSpec
New-Object : Cannot find type : make sure
the assembly containing this type is loaded.
At line:1 char:27
+ $vmConfigSpec = New-Object <<<< VMware.Vim.VirtualMachineConfigSpec
The reason is because the VMware.Vim assembly is not loaded until a call to get-view or find-entityview is made. There are two ways to deal with this:
1. Call get-view or find-entityview before instantiating the object:
PS> $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
New-Object : Cannot find type http://VMware.Vim.VirtualMachineConfigSpec: make sure
the assembly containing this type is loaded.
At line:1 char:27
+ $vmConfigSpec = New-Object <<<< VMware.Vim.VirtualMachineConfigSpec
PS> $vm = get-view (get-vm Snap*).Id
PS> $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
PS>
2: Load the assembly manually:
PS> $vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec
New-Object : Cannot find type http://VMware.Vim.VirtualMachineConfigSpec: make sure
the assembly containing this type is loaded.
At line:1 char:27
+ $vmConfigSpec = new-object <<<< VMware.Vim.VirtualMachineConfigSpec
PS> http://System.Reflection.Assembly::LoadWithPartialName("VMware.Vim")
GAC Version Location
--- -
-
True v2.0.50727 C:\WINDOWS\assembly\GAC_MSIL\VMware.Vim\1.0.0.0__10980...
PS> $vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec
PS>
You can do that using Virtual Infrastructure API and Get-View cmdlet (see )
Try this (using the Beta release):
$vm = Get-View (Get-VM vmname).Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$vm.ReconfigVM($vmConfigSpec);
Hi ykalchev,
I have setup the new Beta1.
I have an error message when created VirtualmachineConfigSpec object... any idea ?
see bellow
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> $vmConfigSpec = N
ew-Object VMware.Vim.VirtualMachineConfigSpec
New-Object : Cannot find type http://VMware.Vim.VirtualMachineConfigSpec: make sure
the assembly containing this type is loaded.
At line:1 char:27
+ $vmConfigSpec = New-Object <<<< VMware.Vim.VirtualMachineConfigSpec
Hi ykalchev,
I have setup the new Beta1.
I have an error message when created VirtualmachineConfigSpec object... any idea ?
see bellow
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> $vmConfigSpec = N
ew-Object VMware.Vim.VirtualMachineConfigSpec
New-Object : Cannot find type : make sure
the assembly containing this type is loaded.
At line:1 char:27
+ $vmConfigSpec = New-Object <<<< VMware.Vim.VirtualMachineConfigSpec
The reason is because the VMware.Vim assembly is not loaded until a call to get-view or find-entityview is made. There are two ways to deal with this:
1. Call get-view or find-entityview before instantiating the object:
PS> $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
New-Object : Cannot find type http://VMware.Vim.VirtualMachineConfigSpec: make sure
the assembly containing this type is loaded.
At line:1 char:27
+ $vmConfigSpec = New-Object <<<< VMware.Vim.VirtualMachineConfigSpec
PS> $vm = get-view (get-vm Snap*).Id
PS> $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
PS>
2: Load the assembly manually:
PS> $vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec
New-Object : Cannot find type http://VMware.Vim.VirtualMachineConfigSpec: make sure
the assembly containing this type is loaded.
At line:1 char:27
+ $vmConfigSpec = new-object <<<< VMware.Vim.VirtualMachineConfigSpec
PS> http://System.Reflection.Assembly::LoadWithPartialName("VMware.Vim")
GAC Version Location
--- -
-
True v2.0.50727 C:\WINDOWS\assembly\GAC_MSIL\VMware.Vim\1.0.0.0__10980...
PS> $vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec
PS>