hi there.
i try some scripts, read some discussions and websites, but have no success to reach our needs.
we have vcenter 5.0 with some datacenters, where some of them have esx cluster and some of them have standalone esx hosts.
we create new alarms to execute external scripts. all works fine and now we want to make our alarms more granular on each of our datacenter. to copy these alarms will be the easy way.
i dont want to make new alarms manual and disable the alarm on the root.
what i need is a handy script which copy three alarms from the root (or the hidden folder datacenter) to all datacenters except two of them and optional disable this three alarms in root.
i try LucD "alarms-moving-them-around", some variants of this and other scripts, but ends up with many errors that i dont understand.
PowerCLI Version: VMware vSphere PowerCLI 5.0 build 435427
thanks!
with the help of lucd i reached our needs. i attached the working script (then you dont need to read all posts )
change line 69 for the dc's that you dont need and in line 70 you can put in the alarms to copy to all other dc's in the connected vcenter.
and thanks again to the holy lucd
Could you attach the errors you get with my script in a file ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Forgot to ask, how do you call the Move-Alarm function ?
In other words, what did you pass on the Alarm, From and To parameters ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i hope you mean this:
$from = Get-Folder -Name "Datencenter"
$to = Get-Datacenter -name "testsystem"
$tgtAlarm = "Testalarm"
$alarms = (Get-AlarmDefinition -name "Neuer Alarm").extensiondata.moref
$alarms | % {
Move-Alarm -Alarm $alarm -To $to.ExtensionData -DeleteOriginal:$false
}
"Datencenter" for a german powercli/vSphere Client/ vcenter - root dir
//edit
ah, i'm sorry. for the first test, i try it with one alarm to understand the script. later i want to expand for three alarms with the productive alarms.
Yes, that is what I meant.
But I suspect that this line
Move-Alarm -Alarm $alarm -To $to.ExtensionData -DeleteOriginal:$false
should be
Move-Alarm -Alarm $_ -To $to.ExtensionData -DeleteOriginal:$false
And I'm not so sure if the value on the To parameter should be a $to.ExtensionData.
Since there seem to be many version of my original script floating around, could you attach the version you are using ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I made a few changes to the attached script.
It will copy 1 alarm, called TestAlarm, to the Datacenter, called testsystem.
Can you give that a try ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It seems like I forgot to define $alarmLength.
Can you change the last lines as follows ?
$alarmLength = 80
$to = Get-Datacenter -name "testsystem"
$tgtAlarm = "neuer alarm"
$alarms = Get-AlarmDefinition -name $tgtAlarm
$alarms | % {
Move-Alarm -Alarm $_ -To $to -DeleteOriginal:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
wuhu great . works like a charm. thanks a lot lucd!
perhaps you can help me to copy three (productive) alarms to all datacenter except the both datacenter "testsystem" and "temp"?
i will give it a try, but for any help im appreciate.
How do you select these 3 alarms ? By name, location... ?
You will have to get all 3 into the $alarms array.
On the To parameter you can specify more than 1 destination.
So you could do something like
$to = Get-DataCenter | where {"testsystem","temp" -notcontains $_.Name}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
by alarm name.
i give it a next try on some dc's before i made it for the whole "farm".
change the last lines of the scripts to:
$alarmLength = 80
$to = Get-DataCenter | where {"testsystem","temp" -notcontains $_.Name}
$tgtAlarm = "test1", "test2", "test3"
$alarms = Get-AlarmDefinition -name $tgtAlarm
$alarms | % {
Move-Alarm -Alarm $_ -To $to -DeleteOriginal:$false
}
some new errors:
- somewhere alarm "test1" will rename to "test" but the description is "original name: test1"
- two errors in powercli that "test" already exist
- 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?
ok there was some crazy problems with existing alarms. delete all these alarms with (for example - need some more to do) the following oneliner:
Get-Datacenter| Get-AlarmDefinition |where {$_.name -match "test"} | %{$_.ExtensionData.RemoveAlarm()}
after that i tried the great script from lucd again and all works fine. thanks a lot!
with the help of lucd i reached our needs. i attached the working script (then you dont need to read all posts )
change line 69 for the dc's that you dont need and in line 70 you can put in the alarms to copy to all other dc's in the connected vcenter.
and thanks again to the holy lucd