2 Replies Latest reply on Feb 6, 2020 6:39 AM by vespavbb

    Copy custom Attribute from vm to vm

    vespavbb Novice

      Hi,

      how can I copy Custom Attributes from VM to VM?

       

      here I have an arry with inputs from the source vm, but how can I set these fileds on the target vm?

      ########

       

      $sourceVM = get-vm -name "vmtest01"

      $TargetVM = get-vm -name "vmtest02"

       

       

      $valueList =@()

      $sourceVM | ForEach-Object {

      for($i = 0; $i -lt $_.CustomFields.Count; $i ++ ){

      $row = "" | Select-Object VMname, FieldKey, FieldValue

      $row.VMname = $_.Name

      $row.FieldKey = $_.CustomFields.Keys[$i]

      $row.FieldValue = $_.CustomFields.Values[$i]

      $valueList += $row

      }

      }

      $valueList

       

       

      ####

       

      $TargetVM  | Set-Annotation -CustomAttribute ??