restore VM custom fields from txt

This topic contains 2 replies, has 2 voices, and was last updated by  Yegor Lopatin 4 years, 6 months ago.

  • Author
  • #12607

    Yegor Lopatin

    Hello Scripting Guys

    I wrote some script for backuping all customs fields of VM

    $input = Read-Host 'Please type hyperv (i.e. hyperv37)'
    $output = "$home"+"\"+$input+"_results.txt"
    remove-item $output -ea SilentlyContinue
    foreach($VM in (get-vm -VMhost $input)){
    	"Name: $VM" >> $output
    	for ($i = 0; $i -lt 9; $i++)
     		"Custom Field [$i]: $($VM.customproperties[$i])" >> $output   
    	"Owner2: $($VM.Owner)" >> $output  
     	"==================================================" >> $output
    Write-Host "results were saved into $output"
    Invoke-Item $output

    How can i restore these fields
    Please advise. Parameter $VM.customproperties seems to be read-only {get}....

    Many thanks

  • #12722

    Richard Siddaway

    Is this for VMware, Hyper-V or what?

  • #12723

    Yegor Lopatin


You must be logged in to reply to this topic.