Hi,
I am looking Powercli command to unregistered/registered Virtual Machine from vSphere 6.7.
Do you want to also delete from disk or just remove from inventory?
Try like this.
Note that this will not delete the VM's files
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Btw, this seems to be the same question you already asked in How to unregister and register Virtual machine vcenter 6.7 via PowerCLI
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
That didn't work.
What didn't work?
Your vSphere connection does not work.
Does your Connect-VIServer work?
And why did you create a new thread?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
That first error message seems to say otherwise, i.e. that you are not connected or that the connection has an issue.
Can you run a regular command?
Like
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference