HI LuCD,
I am opening a new thread to export all alarms whether enable or disable in the Venter. I have taken reference from thread Re: Export All Alarms and definitions from VCenter. but it's not working for me correctly. It's exporting partila number of alarms. I want to export all alarms from vcenter which either enabled or disabled from vcenter. Could you please help me with it.
It's close to working as written. I read back through the whole conversation to get clues, here's where I'm hung up:
WriteError:
Line |
68 | $alarmLength = 80
| ~~~~~~~~~~~~~~~~~
| Cannot overwrite variable alarmLength because it is read-only or constant.
I get that error, not sure what to do about it.
But the main issue is one that SteJeh references in his post, "- the copied alarms in root will be named in "alarm name (moved to dc1, dc2, dc3, dc4, dc5 ... )"; how to change your great script to rename the original name one time?"
So I'll run the script to move the alarm Test1 from DC1 to DC2, and the alarm will stay in DC1 but the name will be changed to "Test1 (moved to DC2). They said they fixed it by deleting the alarm from the target DC (if I'm reading it correctly), but it doesn't even exist in the target DC so I'm not sure where to go from here.
Thanks in advance!
Which version of the script in that thread did you use?
The attachment in the last reply?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, the one SteJah marked as correct and attached - Move-Alarm-v2
The only changes I made to it was I made $to a single datacenter ($to = Get-DataCenter -Name "DC2")
I suspect you ran the script from my Alarms – Moving them around post before.
That script defines the variable $alarmLength as a constant.
If you haven't stopped your PS session, that variable will stay a constant.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Restarted the session and you're right, didn't get that alert. But it's still doing the thing where it doesn't move it, it just renames it. Here's the only error it throws and some screenshots:
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "The object 'vim.Datacenter:datacenter-3' has already been deleted or has not been completely created"
Let me know if you have any thoughts
It looks as if the Datacenter is not found.
Is that Datacenter moved/changed/created after you populate the content of the $destination variable?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This error
The object 'vim.Datacenter:datacenter-3' has already been deleted or has not been completely created
seems to say that the value in $destination is not correct though.
Do a stop/start of your PS session.
Check you have only 1 vCenter connection open.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oh, dang, well that definitely is the problem! I'm trying to copy alarms to a datacenter in a different vCenter instance! Is that not supported?
That should be possible when you have 2 vCenters open and you have the DefaultVIServerMode set to Multiple.
Check with Get-PowerCLIConfiguration and eventually change with Set-PowerCLIConfiguration
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hm, yeah, I have both connected and it was already set to multiple.
Do you have 2 Datacenters with the same name in the 2 vCenters?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try adding the Server parameter with the name of the destination vCenter on the Get-Datacenter cmdlet
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you add a Server parameter on the Get-View cmdlet where the $alarmMgr variable is populated?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference