restore VM custom fields from txt

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Yegor Lopatin Yegor Lopatin 3 years, 5 months ago.

  • Author
    Posts
  • #12607
    Profile photo of Yegor Lopatin
    Yegor Lopatin
    Participant

    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
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    Is this for VMware, Hyper-V or what?

  • #12723
    Profile photo of Yegor Lopatin
    Yegor Lopatin
    Participant

    hyper-v

You must be logged in to reply to this topic.