Long time reader, first time poster.
I've been googling my way for the past few weeks in learning and playing with PowerCLI.
I've gotten to the point where I can create reboot / snap schedules for multiple vms via csv. But only when connected to 1 vcenter.
I currently have vms spread across 9 different vcenters.
The code I wrote, I've copied / pasted and stolen from mostly google and chatgpt.
I'm curious as the error is below
When connected to the vcenter I know the vm is, my schedule for the snapshot creates without issue
When connected to all 9 vcenters, I get the following error, when I'm trying to create 1 schedule for 1 vm. This error is the same unless the vm actually doesn't exist (I plan for error checking later)
----------
Exception calling "CreateScheduledTask" with "2" argument(s): "The object 'vim.VirtualMachine:vm-28758' has already been deleted or has not been completely created"
----------
I assumed the issue was multiple vms with that uid, but no. If I search all 9 vcenters for that UID 28758, only one comes back.
My Script is below... I login to vcenter in another script to keep my passwords out of harm.
When you are connected to multiple vCenters, it is always best to include the Server parameter on cmdlets, like the Get-View cmdlet.
That way you can actually point to the correct vCenter where the VM is located.
Can you give that a try?
You can find the name of the vCenter to be used on the Server parameter with
([uri]$_.Client.ServiceUrl).Host
where $_ is the VirtualMachine object returned by your first Get-View
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LudD Thanks for being so awesome in this community.
I'll give it a try. I'm just starting to understand these Parameters.