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.
Let's start with this one
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
Alarm = $alarm.Name
Description = $alarm.Description
Enabled = $alarm.Enabled
Entity = $alarm.Entity
Action = (Get-AlarmAction -AlarmDefinition $alarm).ActionType -join ' | '
'Last Modified' = $alarm.ExtensionData.Info.LastModifiedTime
'Last Modified By' = $alarm.ExtensionData.Info.LastModifiedUser
})
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What do you want to see in the export, besides Name,Description,Entity,Enabled?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Moderator: You're already actively engaged in another thread - no need to create your own as well.
Thread locked.
scott28tt This request is different, the other thread wanted to have all triggers on a separate line.
Thread unlocked
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks - I'll leave you to it
Let's start with this one
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
Alarm = $alarm.Name
Description = $alarm.Description
Enabled = $alarm.Enabled
Entity = $alarm.Entity
Action = (Get-AlarmAction -AlarmDefinition $alarm).ActionType -join ' | '
'Last Modified' = $alarm.ExtensionData.Info.LastModifiedTime
'Last Modified By' = $alarm.ExtensionData.Info.LastModifiedUser
})
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LuCd,
Thanks for help. It is working perfectly. Need one more help.
What will be script if i want to export these alarms and import in other vcenter to make them as a standard.
We don't want different vcenter at have different alarm definitions , they all should have same definitions.
Thanks
Then you could have a look at KB1032660
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LuCD for help
I am very grateful to LucD for providing this script and helping me a lot. Thank you so much
Was trying to copy alarms VC7 to VC7 without any luck. Is this script support VC7 as well?
My crystal ball is currently out for maintenance, can you provide some more details on how you ran this and what goes wrong?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I was trying to copy alarms and definitions between two vCenter Servers (Version 7 U2) with help of the following VM KB without luck.
That is not a lot of information to go on.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry, my bad. I have a requirement of copying the existing alarms and definition from one vCenter to another vCenter. Both vCenters are in 7.U2
I did the following steps.
Downloaded the scrip from the following VMware KB
https://kb.vmware.com/s/article/1032660
When I tried to run for the first time it gave an error related to the certificate. With the following command, I was able to run script
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
Then I ran the script with the Souce and Destination vCenter information. Script ran without any error throwing but no alarms were copied to the destination vCenter from source vCenter.
I didn't write that script, so you probably have to open an SR mentioning that KB.
To start, did you change line 92 (as the comments state)?
Otherwise only alarms whose name matches "MY.*" will be copied.
Do you see any tasks (Alarm creation) appearing in VC2?
You could enable Verbose output (set variable $verbosePreference to 'Continue') and check if that sheds any light on the issue.
Ultimately you can run the script in an IDE (for example Visual Studio Code) and set some breakpoints.
That might help finding out where things go wrong.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm too lazy a reader. Thank you very much @LucD. It was line 92. I changed and everything working fine.
Thank you once again.
LucD,
This KB is now deleted, is there a copy somewhere I can access? Google can't find it.
Thanks!
The script in that KB hasn't worked since vSphere 6.* it seems.
That probably explains why the KB was removed.
Might the script in Solved: copy alarms from root to many datacenters - VMware Technology Network VMTN help?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Gave it a shot and updated likes 69 & 70 as he suggested, getting more than a few errors from them. I'll poke at them, but if anything comes to mind when you see it please share:
WriteError:
Line |
68 | $alarmLength = 80
| ~~~~~~~~~~~~~~~~~
| Cannot overwrite variable alarmLength because it is read-only or constant.
MethodInvocationException:
Line |
32 | $alarmObj.ReconfigureAlarm($updateAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "ReconfigureAlarm" with "1" argument(s): "A specified parameter was not correct: name"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"
MethodInvocationException:
Line |
32 | $alarmObj.ReconfigureAlarm($updateAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "ReconfigureAlarm" with "1" argument(s): "A specified parameter was not correct: name"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"
MethodInvocationException:
Line |
32 | $alarmObj.ReconfigureAlarm($updateAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "ReconfigureAlarm" with "1" argument(s): "A specified parameter was not correct: name"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"
MethodInvocationException:
Line |
32 | $alarmObj.ReconfigureAlarm($updateAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "ReconfigureAlarm" with "1" argument(s): "A specified parameter was not correct: name"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"
MethodInvocationException:
Line |
62 | $alarmMgr.CreateAlarm($destination.ExtensionData.MoRef,$newAlarm)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: spec"