VMware Communities > Blogs > John Tuffin's Blog > 2008

Blog Posts

John Tuffin's Blog : May 2008

Previous Next
0


This is cool becasue so often I've wanted to modify the boot order of a virtual machine and this little bit of code allows you to do it. I can't remember where I found it now so I can't give credit but thanks to the poster that put this up in the forums.

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.extraConfig += New-Object VMware.Vim.OptionValue $spec.extraConfig[0].key = "bios.bootDeviceClasses" $spec.extraConfig[0].value = "allow:cd,hd" (get-view (Get-VM -Name <VM-name>).ID).ReconfigVM_Task($spec)

0 Comments Permalink
0

Query ESX Time

Posted by cpqarray VMware May 14, 2008

If you're not reading the forum for the VMware VI Toolkit Beta you are missing out on just a goldmine of useful information. Take this post from LUCD. This will allow you to query the ESX host for it's current time. This another one of those instances where there is no applet in the toolkit to do this so you hook into the API to get the information.

Get-VIServer -Server <Replace with yourServer Name>

http://Reflection.Assembly::LoadWithPartialName("vmware.vim")

$svcRef = new-object VMware.Vim.ManagedObjectReference

$svcRef.Type = "ServiceInstance"

$svcRef.Value = "ServiceInstance"

$serviceInstance = get-view $svcRef

$datetime = $serviceInstance.ServerClock

*
Write-Host $datetime

*

0 Comments Permalink
0

I found this example in the VMworld Europe presentation (excellent by the way) that would allow you to move a Virtual Machine from one virtual switch to another.


get-vm vm1 | set-networkadapter "Production"

Now say you wanted to move all vm's from the "VM Network" to "Production"

get-vm | where { ($_ | get-networkadapter).NetworkName -eq"VM Network} | set-networkadapter -networkname "Production"

This would move all VM's from the VM Network to Production.

0 Comments Permalink