Do you want to also delete from disk or just remove from inventory?
if you just want to remove it from inventory without deleting from disk do this:
Remove-VM -VM <EnterVM> -Confirm:$false
If you want to delete the VM entirely from disk then do this:
Remove-VM -VM <EnterVM> -DeletePermanently -Confirm:$false
These commands wont ask you for confirmation they will just do it, if you want it to ask you before doing it just remove the -Confirm:$false
To add the VM back you need some details like the VMX file location, if you run these before you remove the VM from inventory you can gather that info and store it in a variable to use later:
$vmdetails = Get-VM -Name <Enter VM>
$vmname = $vmdetails.Name
$vmfolder = $vmdetails.Folder
$vmxfile = $vmdetails.ExtensionData.config.Files.VmPathName
Then to add the VM back to the folder it was in before:
New-VM -VMFilePath $vmxfile -Location $vmfolder
To start the VM use:
Get-VM -Name $vmname | Start-VM -RunAsync
I have assumed you have already connected the the vcenter server before running these commands.
What didn't work? command which provided for re-register
Your vSphere connection does not work.
Does your Connect-VIServer work? I am able to connect VIserver
And why did you create a new thread? I forgot the preview request I already did, sorry for that