Hi all, thought the following code may help others who are trying to get VMDK's to attached to one VM that were created on another. It helps by answering NO to the question "Do you want to change the disk controller type" at bootup. Note - this code seems quite long, but I'm a beginner and I like to write where I can see exactly what's happening, so you will note a LOT of Write-host statements, feel free to remove if you like.
$sPowerOnMsg = "msg.disk.adapterMismatch:"
$sWinProxy = "VCB_Proxy"
$iChoice = 1 # choice of 1 does NOT change the disk type (choice of 0 does) If you do NOT change (ie - 1) then the question will re-occure each time you boot the VM.
$iVMRestartTimeout = 200
$oWinVM = Get-VM -name $sWinProxy -ea silentlycontinue
$oWinVMv = $oWinVM | get-view
Restart the Proxy VM.
if ($oWinVM.PowerState -eq "PoweredOff")
{
Write-host "VM is Powered Off - Restarting VM : " $sWinProxy
$oWinVM | Start-vm -RunAsync
write-host "started"
Do
{
sleep 10
$iVMRestartTimeout = $iVMRestartTimeout - 10
if ($iVMRestartTimeout -lt 0) {throw "Timeout Error Restarting Proxy VM : $sWinProxy"}
#Recheck the VM state
$oWinVM = Get-VM -name $sWinProxy
$oWinVMv = $oWinVM | get-view
if($oWinVMv.Runtime.Question -ne $null -and $oWinVMv.Runtime.Question.Text.StartsWith($sPowerOnMsg))
{
Write-host $oWinVMv.Runtime.Question.ID
Write-host $oWinVMv.Runtime.Question.Text
Write-host "ProxyVM Asked weather to change DIsk Types, Answering NO ($iChoice)"
Write-host "ANSWERING QUESTION with answer $iChoice"
$oWinVMv.AnswerVM($oWinVMv.Runtime.Question.Id, $iChoice)
}
$sPowerState = $oWinVM.PowerState
Write-host "Sleeping, Timeout is currently $iVMRestartTimeout, PowerState is $sPowerState"
} until ($oWinVM.PowerState -eq "PoweredOn")
}
elseif ($oWinVM.PowerState -eq "Suspended")
{
Write-host "VM is in a Suspended State : " $sWinProxy
throw "Proxy VM is in a suspended state, please shutddown th VM and re-run script: $sWinProxy"
}
else
{
Write-host "VM is already in a Powered on state : " $sWinProxy
throw "Proxy VM is already powered on, please shutddown th VM and re-run script: $sWinProxy"
}
Write-host "Proxy is Powered on : " $sWinProxy
Hope this helps someone :smileyhappy: