Home > Powershell Script > Powershell: Remove-Datastore

Powershell: Remove-Datastore

Here’s the cousin script to the add NFS datastore to multiple esx hosts.

$ds_name = (Read-Host "Enter datastore name to delete")
$vm_hosts = Get-VMHost -Datastore $ds_name

foreach($esx in $vm_hosts)
{
Remove-Datastore -VMHost $esx.Name -Datastore $ds_name -ErrorAction SilentlyContinue -Confirm:$false -RunAsync | Out-Null
Write-Host $ds_name removed from $esx.Name
}

Advertisement
Categories: Powershell Script Tags: , , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.