Last active
July 6, 2017 13:14
-
-
Save meoso/85189e1b33f777c35ae22d896ef2cf2a to your computer and use it in GitHub Desktop.
VMWare SAN SSD UNMAP script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$True,Position=0,HelpMessage="vCenter Server")] | |
[string]$vCenter | |
) | |
# Also Accepts "-Verbose" Flag | |
Write-Host "UNMAPping all volumes on: $vCenter" | |
Import-Module VMware.VimAutomation.Core | Out-Null | |
Disconnect-VIServer * -Confirm:$false -Force | Out-Null #Disconnect all previously connected vcenter servers | |
Connect-VIServer -Server $vCenter -Protocol https -Force | Out-Null | |
$datastores = Get-Datastore | where{$_.Type -eq 'VMFS'} | |
Write-Verbose "VMFS Datastores: $datastores" | |
foreach ($ds in $datastores) { | |
$esx = Get-VMHost -Datastore $ds | Get-Random -Count 1 | |
$esxcli = Get-EsxCli -VMHost $esx | |
Write-Host "Using $esx to unmap $ds" | |
$esxcli.storage.vmfs.unmap($null,$ds,$null) | Out-Null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment