You can try the following PowerCLI code to perform the requested tasks. Change MyVM into the name of the virtual machine that you want to modify. The script waits 60 seconds. Maybe you have to increase that time.
$vm=Get-VM-NameMyVMShutdown-VMGuest-VM$vm-Confirm:$false$HardDisk=Get-HardDisk-VM$vm |Where-Object {$_.Name -eq"Hard disk 3"}Set-HardDisk-HardDisk$HardDisk-PersistencePersistent-Confirm:$falseStart-Sleep-Seconds60if (-not ($vm | Get-Snapshot)) { Set-HardDisk-HardDisk$HardDisk-PersistenceIndependentPersistent-Confirm:$false }Start-VM-VM$vm-Confirm:$false