Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 251495

update virtual machine custom attribute

$
0
0

Hi I am attempting to set a custom attribute "Update Group" for a number of Virtual Machines defined within a CSV file.  We have SRM in our environment and as such I have attempted to filter out SRM placeholders by usingthe gueststate 1. (below)

 

The problem with the follwoing line of code 2. (below) is that $tmp.name appears to be a string and when set-Annotation attempts to update the entity with $tmp.name, it finds both VMs (the running vm and the SRM placeholder)

 

foreach ($row in(import-csv $file))
{
1.      $tmp = get-vm -name $row.Name | get-view | where {$_.guest.guestState -eq "running"}
          write-host $row.name
2.       set-Annotation -entity $tmp.name -customAttribute "Update Group" -value $updateGroup
}

 

IF someone could help with;

 

A. What object ot parse set-annotation -entity

B. A better way to filter out SRM place holders

 

Thanks in advance

 

Error output

 

Set-Annotation : 16/01/2013 4:05:06 PM    Set-Annotation        The specified parameter 'Entity' ex

pects a single value, but your name criteria 'qwpname1' corresponds to multiple values.

At line:1 char:15

+ set-Annotation <<<<  -entity $tmp.name -customAttribute "Update Group" -value "test"

    + CategoryInfo          : InvalidResult: (System.Collecti...dObjectInterop]:List`1) [Set-Annot

   ation], VimException

    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_MoreResultsThanExpected,VMwa

   re.VimAutomation.ViCore.Cmdlets.Commands.SetAnnotation

 

Set-Annotation : 16/01/2013 4:05:06 PM    Set-Annotation        The specified parameter 'CustomAttr

ibute' expects a single value, but your name criteria 'Update Group' corresponds to multiple values

.

At line:1 char:15

+ set-Annotation <<<<  -entity $tmp.name -customAttribute "Update Group" -value "test"

    + CategoryInfo          : InvalidResult: (System.Collecti...dObjectInterop]:List`1) [Set-Annot

   ation], VimException

    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_MoreResultsThanExpected,VMwa

   re.VimAutomation.ViCore.Cmdlets.Commands.SetAnnotation

 

Set-Annotation : 16/01/2013 4:05:06 PM    Set-Annotation        Value cannot be found for the manda

tory parameter Entity

At line:1 char:15

+ set-Annotation <<<<  -entity $tmp.name -customAttribute "Update Group" -value "test"

    + CategoryInfo          : NotSpecified: (:) [Set-Annotation], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Com

   mands.SetAnnotation

 

CSV File Example

 

Name

qwpname1

qwpname2.


Viewing all articles
Browse latest Browse all 251495

Trending Articles