restore VM custom fields from txt

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

Is this for VMware, Hyper-V or what?

hyper-v