Script works does not as expected

Script should auto set annotations for me, it was taken directly from "VMWare vSphere PowerCLI référence" Chapter 5

$VM = get - VM 'test '.

$VM - get-VIEvent-entity Types information |

Where-Object {$_.} GetType(). Name - match "VmBeingDeployedEvent". VmCreatedEvent | VmRegisteredEvent | VmClonedEvent"} |

{ForEach-Object

Set Annotation - entity $VM - CustomAttribute CreatedBy-value $Event.UserName

Set Annotation - entity CustomAttribute - CreatedOn - $VM $Event.CreatedTime value

}

This is the error:

Set Annotation: Impossible to validate the argument on the parameter 'value '. The argument is null or empt

y. provide an argument that is not null or empty, and then try the command again.

The Custom vars.ps1:8 char value: 15

-Value + < < < < $Event.UserName

+ CategoryInfo: InvalidData: (:)) [game-Annotation], ParameterBindingValidation)

Exception

+ FullyQualifiedErrorId: ParameterArgumentValidationError, VMware.VimAutomation.ViCore.

Cmdlets.Commands.SetAnnotation

Set Annotation: Impossible to validate the argument on the parameter 'value '. The argument is null or empt

y. provide an argument that is not null or empty, and then try the command again.

The Custom vars.ps1:11 char value: 15

-Value + < < < < $Event.CreatedTime

+ CategoryInfo: InvalidData: (:)) [game-Annotation], ParameterBindingValidation)

Exception

+ FullyQualifiedErrorId: ParameterArgumentValidationError, VMware.VimAutomation.ViCore.

Cmdlets.Commands.SetAnnotation

However a coupe version of the script:

$VM = get - VM 'test '.

$VM - get-VIEvent-entity Types information |

Where-Object {$_.} GetType(). Name - match "VmBeingDeployedEvent". VmCreatedEvent | VmRegisteredEvent | VmClonedEvent"}

Returns:

Model: false

Key: 1022221

ChainId: 1022221

Createduserid: 17/06/2011 10:52:15

Username: EXAMPLE\Me

Data Center: VMware.Vim.DatacenterEventArgument

ComputeResource: VMware.Vim.ComputeResourceEventArgument

Host: VMware.Vim.HostEventArgument

VM: VMware.Vim.VmEventArgument

Ds                   :

Net                  :

Dvs                  :

FullFormattedMessage: Created the test of the virtual machine on vm6.example.com

ChangeTag:

DynamicType:

DynamicProperty:

I don't know if that makes a difference, but I am running 4.1u1 and 4.0 vSphere powerCLI

Someone knows why?

EDIT: running variable dir: dosent seem to show $Event as existing, $VM is here

You need to replace $Event with $_ because you get the value of the line. Like this:

$VM = Get-VM "test"
Get-VIEvent -Entity $VM -Types Info |
  Where-Object { $_.Gettype().Name -match "VmBeingDeployedEvent|VmCreatedEvent|VmRegisteredEvent|VmClonedEvent"} |
  ForEach-Object {
    Set-Annotation -Entity $VM -CustomAttribute CreatedBy -Value $_.UserName
    Set-Annotation -Entity $VM -CustomAttribute CreatedOn -Value $_.CreatedTime
}

Best regards, Robert

Tags: VMware

Similar Questions

  • The CPL Script works does not on Cisco E Highway

    Hello

    I am trying to download the script to block all the RTC call hit on the highway E in order to avoid any misuse, however the script does not come into force.

    Attached the script and please let me know if something is missing.

    It is downloaded manually until highway E

    I check several post in CSC and it seems a necessity to download manually create rather than through GUI.

    For me the two does not work and call crosses ExpresswayC and CUCM.

    I want to block call to highway E itself, when not authenticated or unknown user sends the RTC call from 9 and +.

    Kind regards

    RACLOT

    You need to have something in the original section, leave empty will only match calls that actually have an empty source field.

    An alternative to using a source address which is supposed to be mapped is to specify the area that runs through the call, in this case because it is an external call entering the highway-E, the appeal will also come from the default Zone.

    Replace:

    unauthenticated-origin=""
    With:
    originating-zone="DefaultZone"
  • Ajax upload script works does not on a single server only?

    Someone has encountered a problem like this before?

    I use a "drag and drop" upload file image streams that works very well on square and 6 other remote hosts, I tried on but it does not work on the remote host, that I really need to work.

    I checked phpinfo and download file is about and what actually upload a picture if I use a direct access and select workflow that is a bit old hat.

    Was wondering if anyone had come across a situation like this before and what to look for in the phpInfo information. I put a call into hosting tomorrow because there must be a server configuration problem, but in the meantime, if anyone has any fire entry away.

    See you soon

    Operating system

    I'm struggling with a related problem right now.  A simple PHP script runs on the local server, but not the Server hosting - grrrrr...

    What PHP version on the server?

    Maybe a permissions issue?  Is the file receiving the image the value just read/write or read/write/execution?

    Nancy O.

  • power cli script works does not in 5.5-was prior work

    I am trying to perform actions on the virtual machines that reside in a csv file.    Here's what I have:

    to connect-viserver $vcenter

    foreach ()$_.name in ("Import-Csv " "$ENV: USERPROFILE\Desktop\vm_list.csv ' -UseCulture)) { }

    $VM = Get-VM $_. name

    Get-VM $VM | Where {$_. PowerState -eq "PoweredOn"} |

    Select Name, Host, NumCpu, MemoryMB,

    @{N='Cpu.UsageMhz.Average';} E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start Get-Date(). () AddHours (-24) -IntervalMins 5 -MaxSamples (12) | Measure-object Value -Average). Average) , 2 )}},

    @{N='Mem.Usage.Average';} E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start Get-Date(). () AddHours (-24) -IntervalMins 5 -MaxSamples (12) | Measure-object Value -Average). Average) , 2 )}} `

    | Export-Csv c:\Temp\stats.csv

    }

    NOTE - If I get rid of the thing whole 'foreach' script works fine Get - VM and down by removing the $VM variable)

    But I want to get the data of perf for VMs on my list, not only of each of them via the GET - VM against the whole vcEnter.

    Any ideas why it's a failure?   in 5.0, I ran a script that mobilized the "foreach" exactly as you see above and it worked great.  Now we are at 5.5 is more does not work.

    Output showing the errors that have baffled me:

    C:\Users\kwg\Desktop\test2.ps1:8 tank: 12

    + foreach ($_.name in (Import-Csv "$ENV:USERPROFILE\Desktop\vm_ip.csv")

    -UseCulture...

    +            ~

    Missing 'in' after variable in the foreach loop.

    C:\Users\kwg\Desktop\test2.ps1:8 tank: 83

    + ... "- UseCulture)) {}".

    +                    ~

    Unexpected token ')' in expression or statement.

    + CategoryInfo: ParserError: (:)) [], ParseException Exception)

    + FullyQualifiedErrorId: MissingInInForeach

    Not sure why you use the pipeline variable ($_____) in the foreach loop?

    There is no need to use a ForEach loop actually, you can pass several names for the Name parameter on the Get - VM cmdlet.

    And then you use the pipeline at its maximum.

    I would like

    to connect-viserver $vcenter

    Get-VM-name (Import-Csv "$ENV:USERPROFILE\Desktop\vm_list.csv" - UseCulture | % {$_.}) Name}) |

    Where {$_.} PowerState - eq "Receptor"} |

    Select Name, host, NumCpu, MemoryMB,

    @{N = "Cpu.UsageMhz.Average"; E = {[Math]: round ((($_ |))} Get-Stat - Stat cpu.usagemhz.average - Start (Get-Date). AddHours(-24)-IntervalMins 5 - MaxSamples (12) | Measure - Object - average value). Average), 2)}},

    @{N = "Mem.Usage.Average"; E = {[Math]: round ((($_ |))} Get-Stat - Stat mem.usage.average - Start (Get-Date). AddHours(-24)-IntervalMins 5 - MaxSamples (12) | Measure - Object - average value). Average), 2)}} |

    Export-Csv c:\Temp\stats.csv

  • missing fonts CS4 script works does not in CS5?

    Hi, my police lack script is working in CS3 and CS4, but does not not in CS4.

    I don't know why, any help please.

    Sam

    Object model has some changes in CS5.

    So use the code below in the upper part of your script.

    app.scriptPreferences.version = 6.0;

  • newText works does not as expected

    Hello all,.

    I am using formCalc.

    My form has a drop-down list box allows this custom text entry. On the change event is a script as follows:

    SubformRecap.TableLiabilityRecap.Row [13]. Cell [1] = xfa.event.newText

    The custom text entered only works when the user:

    • start typing without displaying the menu choices drop-down or completely erases the text of an unwanted choice field
    • then, type the custom text
    • AND then press ENTER

      The script fails to capture the newText if ONE of the following actions occurs

      • does not completely erase the contents of the field drop-down box
      • or highlights and types on the highlighted text
      • or, use TAB instead of ENTRY when you have finished typing

      When it fails the following text/integer appears in the referenced field: 1

      I have limited user so I guess I could train, however, I would like to avoid that if possible. It's a great form and TAB the norm for the entry and exit of the fields. People use it on their laptops in the field - oddities like this in order to have a major nuisance.

      Is the change the right event? Is there a way to enter (ENTER virtual) script?

      Thanks in advance!

      Stephen

      Well, this problem seems interesting... I tried to rebuild, but nothing never is, for me it works in any case so far.

    • Backup of Windows 7 - change the settings - works does not as expected

      I'm trying to configure the backup of Windows 7 by using the "Change settings" option, but when I click on the link, all I get is a the Explorer window showing the contents of c:\Windows\System32

      Same thing if I click on the link 'manage space '.

      What I am doing wrong? or is it a mistake?

      Had the same prob, winlocker and shredder in the context menu, uninstalled winlocker and voila, backup now works.
      So, try to uninstall the software that hangs in the context menu (the menu "right click") and see if it works. Not interested in why at that time [is really starting to enjoy my Kubuntu box]

    • Filling of camera works does not as expected in Android OS 4.0

      Hi all

      Recently upgraded to Ice Cream Sandwich (Android 4.0) on my model of Motorola Xoom Wi - Fi. Love it so far. I seem to have a new problem trying to create a camera effect fill of any kind. Steps to repro:

      • Create any type of layer
      • Press on the '&' > type 'bridge camera '.
      • Try taking a picture; PS Edit then ends in a loop of treatment (with the four squares to the right animation)

      If I try to use the 'back' button Android, I can go back to the Android home screen, and then re - enter PS Touch, who then proceeds to ask me if I want to save my snapshot (which is basically empty). I type any option and everything goes as usual (less PS touch do not take the picture).

      I suspect it has to do with Ice Cream Sandwich and the new drivers for the camera of the Xoom. I tried uninstalling and reinstalling PS Touch that does not solve the problem.

      Other that that, I have not found something else wrong while using PS touch under Ice Cream Sandwich. I notice a very little bit of performance increase also.

      Just thought that I let you know and see if anyone else can repro.

      Version 1.1.1 fixes all my problems. Fonts are back, selections so that work now complete camera very well. Yay!

    • ChageGrep Script works does not in IDCS3

      I have a simple snippet that should do a GrepChange but it seems that he is unable to find the target text. Also, when I try to search through the user interface, it also fails to find the target text. Y at - he looking for a bug documented on grep in InDesign CS3?

      Here's the script:

      app.findChangeGrepOptions = NothingEnum.nothing;

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences = NothingEnum.nothing;

      app.findGrepPreferences.findWhat = "^ $(Anthropology);

      app.changeGrepPreferences.changeTo = "".concat("$1\\t2123")";

      app.findChangeGrepOptions.includeFootnotes = false;

      app.findChangeGrepOptions.includeHiddenLayers = false;

      app.findChangeGrepOptions.includeMasterPages = false;

      app.findChangeGrepOptions.includeLockedStoriesForFind = false;

      app.findChangeGrepOptions.includeLockedLayersForFind = false;

      var app.activeDocument.selection = results [0].parentStory.findGrep (false);

      If (results.length == 0) {}

      $.writeln ("ID not found.");

      }

      I have InDesign v 5.0.4.

      The script works perfectly in CS4.

      Thanks in advance,

      -Jeff

      You cannot assign app.findChangeGrepOptions nothing / null, you must set some or all of its properties to certain values, just as you do a few lines down in your script (like .includeFootnotes = true).

      Peter

    • Show/hide an element with the click of a button - Script works does not in Firefox

      Hi all

      Basically, I'm looking for show/hide a DIV with the click of a button.

      The script works in IE but fail in FF.

      I am sure that I am the problem here.

      <script type="text/javascript">

      function toggle(box) {
           var el = document.getElementById('box');
           el.style.display = (el.style.display != 'none' ? 'none' : '' );
           
           
           value = document.getElementById('content').value;
           if(value=="Show Calendar"){
           document.getElementById('content').value="Hide Calendar";
           }
           else{
           document.getElementById('content').value="Show Calendar";     
      }
      }
      </script>


      <style type="text/css">
      #box{
           background-color: #C0C0C0;
           height: 100px;
           width: 100px;
      }
      </style>
      </head>

      <body>

      <div id="box">
      </div>

      <input id="content" value="Hide Calendar" type="button" onclick="toggle(box)" />
      </body>
      </html>

      WE

      He also worked if you had changed-

      
      

      on this subject.

      
      
    • handheld at 1 pixel brush works does not as expected...

      Hello everyone :-)

      When I try to draw a simple freehandline with the tool draw we get this before I release the mouse button:

      Outline 1.jpg
      That's how I expect the line to be in the final drawing.

      But instead I get this so after releasing the mouse button:

      Outline 2.jpg

      I'm using this brush settings:

      Brush Settings.jpg

      So he must produce a solid rounded 1 pixel brush stroke... In Illustrator CS6 this worked as expected.

      What I am doing wrong? :-o

      All apreaciated advice! :-)


      Have a good day, cyan68

      "Einfach" means "without a brush.

      But: the Brush tool will not work without a brush, he always apply a brush.

      The pencil tool is what you want. Really.

      It works exactly like the Brush tool, but without having to apply a brush.

    • Clean install of windows 7 and firefox 4, java script works does not on various websites

      A clean installation of windows 7 and firefox 4, there is a problem with java script, so far noticed on bbc iplayer (videos do not play) and ebay (pop-up menu options on pages like 'my ebay summary' just don't pop up), everything works fine in internet explore?
      tried safe mode, tried with and without flash and java runtime, everying of compensation has tried, tried to load the settings of internet explore...
      WON'T WORK!

      You have security software with enhanced settings that can block JavaScript in Firefox?

      Create a new profile as a test to see if your profile is the source of the problems.

      See:

      There may be extensions and plugins installed by default in a new profile, so check that in "tools > Modules > Extensions & Plugins" in case there are still problems.

      If this new profile works then you can transfer files from the old profile to the new profile (be careful not to copy corrupted files)

      See:

    • Poster works does not as expected with Adobe CS5

      I've finally updated to OS X on an early 2009 Mac Pro Quad Core. I have two screens: a 20 "Apple Cinema and a Samsung Syncmaster. Previously, always with Snow Leopard, I had no problem with the implementation of my menus, panels, etc on the Samsung, thus leaving my film clean and only to view the picture or painting under development. It's a great ploy.

      But now, I can't have my workspace (menus, panels and so on) to "stick" to the Samsung. Instead, they insist on layering anything I'm working on the cinema, which is now difficult to see behind all the clutter menus and panels.

      I tried to move this to the Samsung, and I saved the arrangement as a new workspace. But the next time and so on, I opened Photoshop, all the menus were back on my film. It is a problem, I expected little, all the problems you may have. But it is serious because I'm not keen on having to pass all the other screen before starting work. In addition, it could be the cause? None of the existing workspaces or those custom made displays on the second monitor except if moved manually.

      I'd appreciate responses as to why this is happening. Thank you

      -Try to reset memory NVRAM/PRAM and SMC

      MacIntel: Reset of the controller (SMC) system management

    • Events in Subvi works does not as expected

      Hi, I'm reposting this question because my previous one did not lead to a satisfactory conclusion.

      I enclose my Vi which do not work as expected. If I remove a Subvi and its controls of 3 partners and two indicators, it works fine, but when I add two screws SUB, it's messy. I'm learning in this way, I don't know it can be done a lot of other ways, but please help me find the problem, do it this way in my final MainVi, I would use Live 8 such void. Thanks.

      Your main problem is the FLOW OF DATA.  A loop can not browse all what it has not completed.  So, as you have, you must have the two structures of event execture before you can go back to look for the next event.  So if you insist on having these subVIs, they must be in separate loops.

      BTW, you can get away with a single Subvi.  Go to the properties of VI and make incoming (preallocated clone).  Then, each call to your Subvi has its own memory space.  Much easier to maintain this mode.

      And I know you said you didn't want alternatives, but here's how you can do it with a unique structure in your main loop.

    • HTTP POST works does not as expected

      I can't understand why the POST with data works when I use Firefox, but not when sent from the BlackBerry. The only difference seems to be that the BlackBerry less sends the headers, but it's all legal HTTP.

      It's TCP data are sent to the server (from recorder package):

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

      HTTP/1.1 POST/page
      Host: localhost
      Connection: close
      Content-Length: 8

      test = abc

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

      That sounds about right. However, the Web Server table $_POST (PHP) is empty.

      Code follows:

           HttpConnection c = (HttpConnection)Connector.open(connectionString);
              c.setRequestMethod(HttpConnection.POST);
      
              DataOutputStream out = c.openDataOutputStream();
              URLEncodedPostData postData = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, true);
              postData.append("test", "abc");
      
              System.out.println("requestData: " + new String(postData.getBytes()));
              out.write(postData.getBytes());
              //out.flush();
      
              c.getResponseCode();
      
              InputStream is = c.openDataInputStream();
              LineReader lr = new LineReader(is);
      
              while(true)
              {
                  try
                  {
                      byte[] arr = lr.readLine();
                      System.out.println("Line: " + new String(arr));
                  }
                  catch(EOFException e) { break; }
              }
      

      Everyone knows about similar problems using POST?

      See you soon,.

      Pav

      Update:

      -J' tried this on 2 servers Web (Apache + PHP) unrelated, both have the same problem.

      SOLVED!

      I tried to put different headers that Firefox sends inside the request of BB and it does the job:

      c.setRequestProperty ("Content-Type", "application/x-www-formulaires-urlencoded");

      Hope it saves someone out there a lot of frustration :-)

    Maybe you are looking for