vCenter alarms and calling a powershell script

OK, I'm missing something or I'm doing something incredibly stupid.

I created a simple powershell script that starts a pre-defined VM. I tested it in PowerGUI, it works fine, no problems so far.

Now all I want to do is set an alarm to ANOTHER VM of vCenter, such that if the virtual machine goes down (power of the off state), the script above is called and "failover" VM is started.

I set up the alarm with a "run a script" action, the script is: "C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe C:\SCRIPTS\FAILOVER.ps1" (including the quotes).

And you guessed it: the script does not run. I'm sure that it doesn't, because the part of the script creates a log file, and this file is not creaed (it IS created when I run the PowerGUI script).

What I am doing wrong? How can I get the alarm to hit my script?

Thank you!

I've never managed to run a PS script this way or the other.

But I found a workaround.

You can start your PS script indirectly via a BAT or CMD file.

That's what I set in the value field

c:\windows\system32\cmd.exe /c c:\Scripts\alarmscript.bat

And the BAT file contained this

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsolefile "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\vim.psc1" -Command C:\Scripts\Test-Alarm.ps1

In the example script I used

Get-VIToolkitVersion | Out-File "C:\Scripts\PSOut.log" -Append
Get-PSSnapin | Out-File  "C:\Scripts\PSOut.log" -Append

Tags: VMware

Similar Questions

  • 'Command' in vCenter alarm

    Hi all

    We are recently receving bunch of vCPU alerts. We want to take these courses of the time period. So, I want to save the info to a database alert.

    I came to know the "run command" in vCenter alarm, which is great. I am able to run the powershell script example using that.

    I wonder if someone can help me on passing the parameters (green, red, metric, vCenterServer name etc.) script powershell is on my vCenterServer. I don't know that there should be a way. Any thoughts or ideas?

    My goal is to send the alarm information to the powershell script and then insert these data in databases so that we can have a story and that you can query easily.

    Thus, whenever there is a generated vCPU alert, powershell script will be executed and insert database values.

    Please let me know if there is a better way to do it.

    Thanks in advance,

    Rajesh.

    I think that the reasoning behind this folderpath and set the AppData environment variables is explained by Carter in step 1.

    These alarm scripts will run under the account of the vCenter Service service, and does not the vCenter uses environment variables.

    The non-existent folder is just a new folder you have to create yourself.

    Can you try to add a Start-Transcript (beginning of the script) and Stop-Transcript (end of the script) to your script?

    This will give you a log of what the script does.

  • How to run multiple Powershell scripts in PowerCLI

    I have a large number of scripts that I would run into lots of PowerCLI. I found a way to call some Powershell scripts from a file of commands like the following (with the permission of Jan Egil Ring), which works very well except for scripts PowerCLI where a connection to a VC or ESX Server must be established before the script can be executed:

    PowerShell-command '& C:\MyScripts\script1.ps1 '.

    PowerShell-command '& C:\MyScripts\script2.ps1 '.

    PowerShell-command '& C:\MyScripts\script3.ps1 '.

    If a VC connection is on using Connect-VIServer PowerCLI, then scripts can each be run from the prompt without connection information and credentials, however, if scripts are placed in a file of DOS commands, it is necessary to place an order Connect-VIServer in each script, which will prompt you for credentials every time , so if I have 10 scripts, I will have to enter the credentials of 10 times. Is it possible to establish the connection and then run a set of Powershell scripts, or is there a way to integrate the identification information in the script so that it will connect to the VI server without asking confirmation?

    Thank you

    Ed Z

    2 options 1 persist credentials on disk, you can find the code on poshcode.org to do.

    Option 2 is to use - Session when using Connect-VIServer. The session is stored in the variable $defaultVIServer. If write you it to a file you can load this file and re-use this same session, assuming that it is still valid (i.e. it has not expired.)

  • Unable to collect vCenter alarms/tasks/events

    Hello

    I have a journal Insight 3.0 and installing vCenter Server 5.5 U2b environment.

    I created a clone of Read-Only and add the following permissions:

    Global.Licenses

    Global.SetCustomField

    Host.Config.AdvancedConfig

    Host.Config.NetService

    Host.Config.Network

    Host.Config.Settings

    System.Anonymous

    System.Read

    System.View

    This role is spread from data centers (upper level) and connected to an AD user account.

    When I integrate Log Insight with my any snippet vCenter and it is saved correctly in the Administration tab for the particular Server vCenter (collect vCenter Server events, tasks and messages is checked), but nothing ever appears in vCenter alarms / tasks despite the fact that there are a lot of things for at least a month back. I use a custom range, which should be enough.

    I tried the same thing in our development environment with an administrator privileged account and it works fine, I get a lot of vCenter alarms and whatnot in the dashboards. However, I want to use the least permissions if possible.

    Am I missing a permission/privilege? Is there a log file I can check for errors/warnings?

    Can be set to RESPOND.

  • In the Powershell script execution error: could not find the type [ordered]: make sure that the assembly containing this type is loaded.

    People,

    I am trying to load and run the PowerShell script of PowerCLI Module to check the CPU, memory and storage overcommitment. VMware PowerCLI Blog - VMware Blogs but somehow it is always stopped with the error: cannot find the [ordered] type: make sure that the assembly containing this type is loaded.

    Here are some of the diagnostic result:

    $PSVersionTable

    Value name

    ----                           -----

    PSVersion 2.0

    PSCompatibleVersions {1.0, 2.0}

    BuildVersion 6.1.7601.17514

    PSRemotingProtocolVersion 2.1

    WSManStackVersion 2.0

    CLRVersion 4.0.30319.1026

    SerializationVersion 1.1.0.1

    Get-ChildItem ' HKLM:\SOFTWARE\Microsoft\NET frame Setup\NDP'-recurse |

    Get-ItemProperty-name of the EA - 0 Version |

    Where {$_.} PSChildName-match ' ^ (?) (S) \p {L} "} |"

    Select PSChildName, Version

    PSChildName Version

    -----------                       -------

    v2.0.50727 2.0.50727.5420

    3.0.30729.5420 v3.0

    Windows Communication Foundation 3.0.4506.5420

    Windows Presentation Foundation 3.0.6920.5011

    3.5.30729.5420 v3.5

    Customer 4.0.30319

    4.0.30319 full

    Get-PowerCLIVersion

    PowerCLI Version

    ----------------

    VMware vSphere PowerCLI 5.8 Release 1 build 2057893

    ---------------

    Versions of the snap

    ---------------

    Build VMWare AutoDeploy PowerCLI component 5.5 1983942

    Build VMWare ImageBuilder PowerCLI component 5.5 1983942

    Build license of VMware PowerCLI component 5.5 1265954

    Build VMware Storage PowerCLI component 5.8 2057894

    Build VDS's VMware PowerCLI component 5.8 2031581

    Build VMware vSphere PowerCLI component 5.8 2031581

    I installed Windows6. 1 -KB2819745- x 64 - MultiPkg.msu to enable Powershell v4.0 on my Windows 7 laptop, but still the script cannot be executed with the above error message.

    Any kind of aid and assistance would be greatly appreciated.

    Thank you

    Hello-

    Ah, yes--it is that review.

    Another option, because you are not able to go to .NET FX 4.5, is to remove the parts "[ordered]' of the code that you use.  This type Accelerator makes the hash table a dictionary sorted.  The effect to remove that from the code will be that the properties of the object that results will not be in the order in which they appear in the code.

    And, another option would be to install PowerShell v3 (the version in which the '[ordered]' feature has been added').  That shouldn't require a FX .NET newer than what you showed as having already installed on this computer.  However, as we have seen with the PSSnapin and PSv4 Exchange, you want to make sure that the PSSnapins / Modules you want to use are compatible with PowerShell v3.

  • export and import vcenter alarms

    Hello

    I'm working on the migration of all the alarms configured production vcenter (running on 5.1) to another (race with 5.5). Y at - it a medium CLI script or the power to perform the same task.

    your quick response will be highly appreciated. I need this bad.

    Please see the resources below

    VMware KB: Restoration and copy of the Server vCenter alarms

    Download | stripeyfish

    Import/export script alarms between VC or synchronize alarms between 2 virtual centres

  • PowerShell script and the Orchestrator

    Hi guys

    We managed to set up the PowerShell script to run a task in the Orchestrator, the only problem is that we cannot pass the input parameter

    $vCOuser = "xxxxxxxx".

    $vCOpass = "zzzzzzzz.

    $vCOparm = "C:\orchestrator\Test.html".

    # Se connect to vCO and generate proxy $vcoWS

    $vcoWS = New-WebServiceProxy - Uri http:// < server >: 8280/vmware-vmo-webcontrol/webservice? WSDL

    # Print the result

    $vcoWS

    # Find Workflow

    $workflow = $vcoWS.getWorkflowsWithName ("create a simple XML document", $vCOuser, $vCOpass)

    # Print the result

    $workflow

    foreach ($element in $workflow)

    {

    $element.id

    #... and run

    $workflowToken = $vcoWS.executeWorkflow ($element.id, $vCOuser, $vCOpass, inParameters)

    # Print the result

    $workflowToken

    }

    Any help would be appreciated

    Hello!

    You can specify an array of WorkflowtokenAttribute objects and pass it to the executeWorkflow method:

    $inparams += New-Object -TypeName VCO.WorkflowTokenAttribute
    $inparams[0].name = "inputString"
    $inparams[0].type = "String"
    $inparams[0].value = "Hello World"
    
    $inparams
    
    # ... and exectue (use $null instead on $inparams if Workflow has no input parameters
    # ... und ausführen
    $workflowToken = $vcoWS.executeWorkflow($workflow.id, "vcoadmin1" , "VMware2010", $inparams)
    $workflowToken
    

    See the complete example here:

    http://www.vcoportal.de/2011/06/updated-calling-VCO-workflows-from-PowerShell/

    http://www.vcoportal.de/examples/PowerShell-VCO/

    Kind regards

    Joerg

  • Unable to wait 30 seconds and then call the TCL Script as Action?

    Hello and good afternoon all!

    I was browsing through different threads and did some research and I am unable to get my applet to wait 30 seconds and then call a script TCL to a succession of 'action '.  Here is the Basic script I am trying to run:

    Event Manager applet track-loopback1
    Event track 10 down state
    command action 1.0 cli 'enable '.
    Action 1.1, «config t» cli command
    Action 1.3 cli command "event manager applet-counting backwards.
    action 1.4 cli command 'event timer countdown 30 '.
    action 1.5 cli command "action 1.0 wait 30.
    Action 1.6 cli command "end".
    Action 1.7 cli command "tclsh Loopback1 - Notification.tcl.

    The goal of this applet is simply wait interface Loopback1 go down, and then launch the applet "-Countdown ' which waits 60 seconds before calling end my TCL script.  The pattern of ' countdown time 30 "and the" action 1.0 wait 30 "is my (lack of?".  :-)) understand that after counting 30 I need to a trial of the action - but I'm not 100% clear on this?  Ironically, he does, in fact, call the TCL script, it does not wait 30 seconds.  My current workaround is to simply throw a statement "after 30000' in the TCL script, but I'm really curious to know why it does not work as expected (well, as I expected to work anyway!).  Any help would be GREATLY appreciated.  Thank you very much!

    See you soon,.

    Travis

    See my response to https://supportforums.cisco.com/discussion/13009231/eem-applet-wont-fire... .  What you do not work, so you should not call tclsh to EEM anyway.

  • Re: Script to retrieve vCenter roles and responsibilities

    Hello guys,.

    I need a script to do the following

    The script should generate the following details in a csv format: vCenter roles and responsibilities-> AD groups assigned to this role-> privileges assigned to this role.

    vCenter roles name
    (List of all roles)
    Details on using
    (Inscription on the groups or users
    added to the particular role)
    List each of the role privilege.
    For example: data center-> Global etc...

    Thank you

    VK

    Hello

    Always try to LucD scripts, it is one of the best scripter, check below one of his screenplay

    http://communities.VMware.com/message/1642302

    Thank you

  • Call the batch file and not the shell script using measures of the event

    Can I use EVENTACTIONS at the door of gold like

    eventactions (SHELL, /path-to-batch-file/test1.bat)

    will this work? I am on a windows machine, so I need to run a batch file and not a shell script

    In GGSCI, you can shell OUT to the BONE and call a command/executable file.

    For example on Windows:

    GGSCI (WIN2003) 2 > shell dir

    Volume in drive C has no label.

    Volume serial number is 8CCC-9E58

    Directory of C:\ggs

    18/08/2012 07:23

    .

    18/08/2012 07:23

    ...

    2010-10-15 06:37 bcpfmt.tpl 426

    2010-10-15 06:37 bcrypt.txt 1 725

    22/04/2011 03:41 2 560 category.dll

    05/11/2011 10:43

    cfg

    2010-10-15 07:15 739 chkpt_ora_create.sql

    ...

    What were the results when you tried this in an EVENTACTIONS clause?

  • Smart talkband is not an alarm sound for notifications and calls

    Dear friends
    I have talkband2 of sony which I use with huawei mate7 phone. All options are ok but don't have audio for notifications and calls and have only vibrator.so I want to know what is happen when I press the volume keys?

    Yes, I have and never had audio notifications unless you put it to load or you get a prize for having reached the steps or calories (first band should be on the volume).

  • Running Powershell script with ESXCLI commands via a scheduled task in Windows 2012 does not work.

    I'm trying to run a powershell script of a scheduled task in Windows 2012. The script calls the commands ESXCLI and ends with success (exporting to a CSV file) but the file has no data inside.  If I run the script manually without the scheduled task file has all the I expect to exit.

    I wonder if there is a framework with Powershell or a PSSnapin I need to add to the script for it to run via a scheduled task.  Has anyone done this before with the ESXCLI commands?

    panhvr - you may to something.  The process account that I use to run this script has only read-only access in vCenter.  I logged on the server I am running these reports with the process ID and tried to run the script.  He gave me errors indicating permission to perform the operations of esxcli was denied.

    I think we found the culprit!  I'll have this process ID in vCenter rights upward.

    Thank you all!

  • vCenter alarms &amp; SNMP Trap

    Gang-

    I try to get my vCenter alarms to send traps SNMP for SNMP Manager/receiver so we can automatically open the service tickets based on certain types of vCenter alarms.  I have loaded MIB and OID translate for VMWARE-VC-EVENT-MIBs.

    Everything goes well and using the free utility TrapReceiver I'm able to test receive interrupts.

    Here's my problem...

    I don't know how vCenter is differentiate the name of alarm vCenter in trap data.  Some vCenter alarms/traps, I want my ticket system to open lower or higher priority tickets, so I need to figure out how vCenter translated the alarm at the "vmwVpxdObjValue" into the trap.  Unfortunately I can't find any information on how to translate this value and I don't want to wait for all my events to trigger production, just to get a sample, so I don't know what to expect.

    Any ideas?

    VMWARE-VC-EVENT-MIB

    vpxdAlarmInfo

    notification

    OID - 1.3.6.1.4.1.6876.4.3.0.203

    Thank you

    Well shoot - that isn't quite right either.

    Seems that if it is a fault of the alarm system, the TRAP will leverage the value of $alarm.extensiondata.info.systemname as the beginning of the vmwVpxdObjectValue data.

    If it is a user/custom alarm, it seems to refer to the value of $alarm.extensiondata.info.name.

    I have to have a script that includes both.

  • reviews - type of powershell script script error is not valid for OS null

    I use the comments script manager to run the script on a newly cloned VM Windows Powershell. In my main workflow, I call several workflows VM (upgrade tools, vm stop, move DS, etc.) whose use: attribute called type newVM VC:VirtualMachine. I added a new secondary workflow to run the Script to run as a guest VM. I did like the others under workflow and related virtual machine of the VC:VirtualMachine parameter to the newVM. Also limited the parameters of user name and password. I can run the subworkflow run the Script in guest VM by itself without any problem. However, when I run the main workflow which is the integrated subworkflow, I get this error: powershell script type is not valid for OS null

    Yes there is, when editing a workflow schema in Basic on the left side is a tool of sleep.

  • PowerShell Script - Annotations to CSV

    Hello everyone!

    I need a liitle powershell script that does the following.

    Get all the VM and when "CustomAttribute" is set to 1, write the values such as CPU, RAM,... in a csv file.

    I tried like this:

    $VMExport = get - VM | Get-Annotation CustomAttribute - Export | Where-Object {$_.} {Value - eq 1}

    But now, I have only the value 1 in the Variable '$VMExport' and can not use it for more things.

    Can someone help me with this?

    The CustomFields is a hash table, you can access the values by using the key as the index.

    You will need to use a property calculated for this

    $VMExport = Get-VM | where {Get-Annotation -Entity $_ -CustomAttribute Export | Where-Object {$_.Value -eq 1 }} |
    Select Name,ProvisionedSpaceGB,MemoryMB,NumCpu,Description,   @{N="Custom Field";E={$_.CustomFields["CustomFieldName"]}}
    

    It retrieves the value of the custom field called 'CustomFieldName' and it appears under the "Custom Field" property.

Maybe you are looking for

  • Satellite C660D - cannot install Wireless Lan / WiFi driver

    recently I had to reinstall a satellite c660d (amd processor) with windows 7 from dvd. installation disk hard form was not possible more. Problem is that I can't install a driver from networkcontroller and also card wireless network does not work. I

  • Spectrum x 360: no wifi after network installed windows 8.1 on new spectrum HP 360

    Hi all I bought this computer just and necessary for the upgrade to windows 8.1 with specific software, I need to run on a windows machinw 8 current execution. The facility was good until I got to connect to wifi and nothing has been shown. I followe

  • Filters on the fans / vents?

    Bit of a newb here in question, but I was aspiration of dust on the inside of my HP Pavilion Elite m9252p today and noticed how much dust accumulated outside the various vents on the sides of the chassis, not to mention inside. Is it safe to put the

  • Predator XB271HU G-Sync on?

    Hi, I have just had my monitor (XB271HU) and follow the instructions in 'spin' on G-Sync. The thing is how to know is turned on? Windows, game mode mode (full screen) still shows blue LED. I use Geforce GTX980 Ti. Need help & thank you!

  • XP PRO SP3 Gone Away print spooler

    My granddaughter was over last night and now all my printers have disappeared. I ran the MS Fix and yet it says the or is not running. Any suggestions?