TomTom30
TomTom30

Reputation: 35

Delete VMDK file with powershell/powercli command?

I'm a little bit stuck because I would like to delete some VMDK file from vSphere with a PowerShell or PowerCLI command.

I know how to do that from the vSphere vCenter GUI but I didn't find how to do that with a command.

Do you think that there is a way to do that with something like:

Remove-Item path/to/my/VMDK

If someone has already made this, can you show me how?

Upvotes: 1

Views: 1009

Answers (2)

NickMartin
NickMartin

Reputation: 111

You can also remove the vmdk file with the powercli Remove-Harddisk cmdlet (with -DeletePermanently you physically remove the vmdk from the datastore).

Upvotes: 0

Kyle Ruddy
Kyle Ruddy

Reputation: 2121

You could use the vmstores PSDrive option that will allow you to use standard PowerShell functionalities alongside an authenticated vSphere session.

Example of polling your available datastores:

dir -Recurse -Path vmstores:\

Additional info: Browse datastores using PowerCLI

Upvotes: 0

Related Questions