I'm working on a script to mass deploy VM's from a CSV-file (thanks all who've helped in my previous post/s). I have entered data for 2 servers in the CSV-file. The script can deploy from either a template or blank (without OS) with only the data of the CSV-file. This script was working fine until I suddenly, without any changes to the script mind you, recieved this error:
PowerCLI C:\Temp\> .\NewVM-1.1.ps1
New-VM : 2013-04-18 12:51:49 New-VM Operation is not valid due to the current state of the object.
At C:\Temp\NewVM-1.1.ps1:55 char:9
+ New-VM -Template $Template `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.NewVM
New-VM : 2013-04-18 12:51:53 New-VM Operation is not valid due to the current state of the object.
At C:\Temp\NewVM-1.1.ps1:55 char:9
+ New-VM -Template $Template `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.NewVM
As you see above this is when I specified a template. At the moment this doesn't happen when I don't use template, but it did that too before.
PowerCLI C:\Temp\> .\CleanUp.ps1
Remove-VM : 2013-04-18 12:51:59 Remove-VM Operation is not valid due to the current state of the object.
At C:\Temp\CleanUp.ps1:2 char:5
+ Remove-VM $row.Name -DeletePermanently -Confirm:$false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.RemoveVM
Remove-VM : 2013-04-18 12:52:00 Remove-VM Operation is not valid due to the current state of the object.
At C:\Temp\CleanUp.ps1:2 char:5
+ Remove-VM $row.Name -DeletePermanently -Confirm:$false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.RemoveVM
CleanUp-script removes the VM's created. At the moment this happens even if the VM's were created without error.
Even though I recieve the error the VM's are created/removed, but the rest of the script won't continue because of it (such as add extra hard drives and annotations). Also, it isn't every time that I get the error, sometimes both VM's are create, sometimes 1 of the two and sometimes none.
Some information that might help regarding our test environment that I run the script in:
Not running Power GUI (yes, i've read http://communities.vmware.com/message/1702069).
PowerCLI Version:
PowerCLI C:\Temp\> Get-PowerCLIVersion
VMware vSphere PowerCLI 5.1 Release 2 build 1012425
PowerShell Version:
PS C:\Users> get-host
Name : ConsoleHost
Version : 3.0
As stated in http://communities.vmware.com/message/2146831, previously there wasn't support for Powershell 3, but from what I understand of http://blogs.vmware.com/vipowershell/2013/02/powercli-5-1-release-2-now-available.html that shouldn't be a problem anymore.
My question is therefor: What reasons are therewhich might cause this error?