VMware Cloud Community
arbelac
Contributor
Contributor

Wait-tools - Error: "Input string was not in a correct format."

Hi,


when attempting to power-on VM then I got the following error message.

Script :

Start-VM -VM $updateTempName -Confirm:$false

Start-sleep -s 20

Wait-Tools $updateTempName


Message:

Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
2016GoldenImage PoweredOn 2 4.000
Wait-Tools : Cannot bind parameter 'TimeoutSeconds'. Cannot convert value "2016GoldenImage" to type "System.Int32". Error: "Input string was
not in a correct format."
At line:5 char:12
+ Wait-Tools $updateTempName
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Wait-Tools], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.WaitTools
0 Kudos
3 Replies
LucD
Leadership
Leadership

The Wait-Tools cmdlet is confused by the parameter you passed.
Normally the cmdlet uses the 1st unnamed parameter as the value for the VM parameter, but I guess that the OBN (Object By Name) might interfere.

If '2016GoldenImage' is indeed the name of the VM, can you try with

Wait-Tools -VM $updateTempName

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

arbelac
Contributor
Contributor

You're right. Now its work very well. btw I have modified my script. a little paranoid  🙂 

btw Is there extra recommended for below power-on control ?

Start-VM -VM $updateTempName -Confirm:$false

Start-sleep -s 20

Wait-Tools -VM $updateTempName

do { $ToolTest = (Get-VM $updateTempName).ExtensionData.Guest.ToolsStatus ; start-sleep 5 }

until ($ToolTest -eq "toolsOk")

Write-Host "Performing Invoke Operation on $($updateTempName.Name)"

  

0 Kudos
LucD
Leadership
Leadership

I personally rarely use the Wait-Tools cmdlet.
When I have to wait for the VMware Tools to be ready to receive code via Invoke-VMScript, I normally use a loop like this

$vm = Start-VM -VM $updateTempName -Confirm:$false

do {
  sleep 5
  $vm.ExtensionData.UpdateViewData('Guest')
}
while(-not $vm.EXtensionData.Guest.guestOperationsReady)

Write-Host "Performing Invoke Operation on $($updateTempName.Name)"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference