It has been a while, please remind me how to put code in here? PSVersion 5.0.10105.0 VMWare AutoDeploy PowerCLI Component 6.0 build 2358282 VMWare ImageBuilder PowerCLI Component 6.0 build 2358282 VMware License PowerCLI Component 6.0 build 2315846 VMware vSphere PowerCLI Component 6.0 build 2548068 VMware VDS PowerCLI Component 6.0 build 2548068 VMware Cloud Infrastructure Suite PowerCLI Component 6.0 build 2548068 VMware HA PowerCLI Component 6.0 build 2510422 VMware PowerCLI Component for Storage Management 6.0 build 2522368 Trying to build a server from the ground up using Powercli. Started With:
$paramVM = @{
VMHost = $vmhost
Version = "v7"
Name = "CompVM"
Datastore = $datastore
DiskGB = 50
DiskStorageFormat = "EagerZeroedThick"
MemoryGB = 4
NumCpu = 1
Location = $Folder
CD = $true
ResourcePool = $ResourcePool
Portgroup = $portGroup
Notes = "DOM Domain Controller"
Confirm = $false
}
$paramVM.Location | select *
New-VM @paramVM
This seemed to go pretty well.
Get-VM svr01mid100 | Start-VM
Then something isn't quite right.
$paramNA = @{
StartConnected = $true
WakeOnLan = $true
Connected = $true
Type = 'Vmxnet3'
Confirm = $false
}
Get-VM chi01osm300 | Get-NetworkAdapter | Set-NetworkAdapter @paramNA
I get the error: Set-NetworkAdapter : 7/29/2015 6:44:36 PM Set-NetworkAdapter Operation is not valid due to the current state of the object. At line:9 char:43 + Get-VM svr01mid100| Get-NetworkAdapter | Set-NetworkAdapter @paramNA + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Set-NetworkAdapter], VimException + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.SetNetworkAdapter MacAddress : 00:10:56:ss:3f:ab WakeOnLanEnabled : True NetworkName : SameAsAbove Type : Vmxnet3 ParentId : VirtualMachine-vm-108361 Parent : svr01mid100 Uid : /VIServer=Dom\me@avCenter.Dom.com:443/VirtualMachine=VirtualMachine-vm-108361/NetworkAdapter=4000/ ConnectionState : Connected, NoGuestControl, StartConnected ExtensionData : VMware.Vim.VirtualVmxnet3 Id : VirtualMachine-vm-108361/4000 Name : Network adapter 1 Client : VMware.VimAutomation.ViCore.Impl.V1.VimClient
Get-VM svr01mid100 | Get-CDDrive | Select Name,IsoPath
Name IsoPath ---- ------- CD/DVD drive 1 PS C:\> Get-VM svr01mid100 | Get-CDDrive | Set-CDDrive -IsoPath $isoPath -StartConnected $true -Confirm:$false Set-CDDrive : 7/29/2015 6:50:39 PM Set-CDDrive Operation is not valid due to the current state of the object. I have disconnected my session and reconnected. I tried to see what was going on in vCenter (which I never do) and I fount it trying to boot off the ISO but giving a frowning face and rebooting again. i am thinking it did not like something in the sever build. HELP!
I am not sure I made this clear enough.The new VM script seems to be working, it creates a new VM.
But afterwards, Every setting change I try to make on the VM, I get an error saying "Operation is not valid due to the current state of the object."
It seems to take the configuration but then I noticed that it was trying to boot up, but it was getting the error that i put in the screen shot.
To me this shows that it is trying to boot off of the CD, because it is a Windows error. By the way, it just tries to boot over and over again.
Now I have gone back and i think the "Operation is not valid due to the current state of the object" error may have been do to the fact that the VM was trying to boot from the CD over and over, this is what was meant by current state.
I also just noticed that the hosts here have 4.1 on them, which doesn't support Server 2012 r2.
I think we are good. Thanks!
Did you change the BIOS boot order before starting the VM ?
See for example Specify the boot devices for a virtual machine
See 4. Re: Powercli Script required to list all the clusters in a datacenter and all hosts within each clus...
for info on how to enter colour-coded PowerShell code.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am not sure I made this clear enough.The new VM script seems to be working, it creates a new VM.
But afterwards, Every setting change I try to make on the VM, I get an error saying "Operation is not valid due to the current state of the object."
It seems to take the configuration but then I noticed that it was trying to boot up, but it was getting the error that i put in the screen shot.
To me this shows that it is trying to boot off of the CD, because it is a Windows error. By the way, it just tries to boot over and over again.
Now I have gone back and i think the "Operation is not valid due to the current state of the object" error may have been do to the fact that the VM was trying to boot from the CD over and over, this is what was meant by current state.
I also just noticed that the hosts here have 4.1 on them, which doesn't support Server 2012 r2.
I think we are good. Thanks!