Feb 282014
 

This One Line of code will list the count of VMs on each datastore in the Datastore Cluster
Just edit the datastore cluster name below:

foreach($a in (get-datastorecluster MyDataStoreCluster | get-datastore)){write-host $a ($a | get-vm).count}

List will look like this:

Datastore-1 12
Datastore-2 10
Datastore-3 9
Datastore-4 1
Datastore-5 42

Feb 262014
 

This will check your ESXi host and tell you which LUNs support VAAI primitives.

 
$hostname = “myhost.pcli.me”

$report2 = @()
$Datastorelist = get-vmhost $hostname | Get-Datastore
foreach ($ds in $datastorelist) {
$reportrow = “” | Select DatastoreName,CName
$reportrow.DatastoreName = $ds.Name
$reportrow.CName = $ds.extensiondata.info.vmfs.extent | %{$_.diskname}
$report2 += $reportrow
}
$temp = get-esxcli -vmhost $hostname | %{$_.storage.core.device.vaai.status.get()}
$report = @()
foreach($a in $temp){
$ReportRow = “” | Select-Object Hostname,LunName,Device,ATSStatus,CloneStatus,DeleteStatus,VAAIPluginName,ZeroStatus
$ReportRow.hostname = $hostname
$ReportRow.LunName = $report2 | where {$_.cname -eq $a.Device} | %{$_.datastorename}
$ReportRow.Device = $a.Device
$ReportRow.ATSStatus = $a.ATSStatus
$ReportRow.CloneStatus = $a.CloneStatus
$ReportRow.DeleteStatus = $a.DeleteStatus
$ReportRow.VAAIPluginName = $a.VAAIPluginName
$ReportRow.ZeroStatus = $a.ZeroStatus
$report += $reportrow
}
$report | Ft -a

Jun 202013
 

We found an issue where the SAN wasn’t using VAAI commands correctly.
So,  we need to disable it.
Here is the code to do that:

$allhosts = get-vmhost
foreach($singlehost in $allhosts){
Set-VMHostAdvancedConfiguration -VMHost $singlehost -Name DataMover.HardwareAcceleratedMove -Value 0
Set-VMHostAdvancedConfiguration -VMHost $singlehost -Name DataMover.HardwareAcceleratedInit -Value 0
Set-VMHostAdvancedConfiguration -VMHost $singlehost -Name VMFS3.HardwareAcceleratedLocking -Value 0
}

Value of 1 = Enabled
Value of 0 = Disabled

VMware Link:
https://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/Set-VMHostAdvancedConfiguration.html

Jun 112013
 

This will enable Storage IO Control for all datastores that exist within a datastore cluster for the entire vcenter.
Edit as needed:

set-datastore -datastore (Get-DatastoreCluster | get-datastore) -StorageIOControlEnabled $true

 

Quick edits if you want a narrow scope:
Single Cluster:
set-datastore -datastore (Get-DatastoreCluster “MyStorageCluster”| get-datastore) -StorageIOControlEnabled $true

With a filter to only change datastores with “ThisText” in the name:
set-datastore -datastore (Get-DatastoreCluster | get-datastore | where {$_.name -match “ThisText”}) -StorageIOControlEnabled $true

 

Vmware Links:
http://www.vmware.com/support/developer/PowerCLI/PowerCLI51/html/Set-DatastoreCluster.html
http://www.vmware.com/support/developer/PowerCLI/PowerCLI51/html/Get-Datastore.html

May 312013
 

This code will get all of the host names in a cluster, parse the names (if you use FQDN for your hostnames), and rename the default “datastore1″ to “hostname-local” format
This will help resolve the issue of having a lot of “datastore1 (99)” showing in your Datastores view.
***Note, if you use the word “datastore1″ for other storage locations or have a host with more than one local storage device named “datastore1″ this may explode.

$hostnames = get-cluster mycluster | get-vmhost | %{$_.name}
foreach($ahost in $hostnames){
$one1 = $ahost.split(“.”)
$two2 = $one1[0]
$thename = $two2+”-local”
get-vmhost $ahost | get-datastore | where {$_.name -match “datastore1″} | set-datastore -name $thename
}

Vmware Link:
http://www.vmware.com/support/developer/PowerCLI/PowerCLI51/html/Set-Datastore.html