# encoding: ascii
# api: powershell
# title: Get-mDatastoreList
# description: A version of the VMware Get-Datastore cmdlet that filters out datastore we don’t want to put VMs on.  It filters by type of datastore and our naming conventions for the datastore naming indicating what kind of data is on the datastore.  Line 9 will have to be updated for your own environment.
# version: 0.1
# type: function
# author: monahancj
# license: CC0
# function: Get-mDatastoreList
# x-poshcode-id: 3522
# x-archived: 2014-02-09T10:36:58
# x-published: 2014-07-17T07:12:00
#
#
Function Get-mDatastoreList {
#Parameter- Name of the VMware cluster to choose a datastore from.
param($Cluster)

#get alphabetically last ESX host in the VMware cluster (it's likely the last host added to the cluster, so this might smoke out any problems)
$VMH = get-vmhost -Location $cluster | Where-Object { ($_.ConnectionState -eq "Connected") -and ($_.PowerState -eq "PoweredOn") } | Select-Object -Property Name | Sort-Object Name | Select -Last 1 -Property Name

# Get all the datastores, filtered for exclusions
$DSTs = Get-Datastore -VMHost $VMH.Name | Where-Object { ($_.Type -eq "VMFS") -and ($_.Name -notmatch "local") -and ($_.Name -notmatch "iso") -and ($_.Name -notmatch "template") -and ($_.Name -notmatch "datastore") -and ($_.Name -notmatch "temp") -and ($_.Name -notmatch "decom") -and ($_.Name -notmatch "_BED-PR") -and ($_.Name -notmatch "VMAX") -and ($_.Name -notmatch "NEW")  -and ($_.Name -notmatch "MAY-PR-LEG") -and ($_.Name -notmatch "BED-QA-LEG") }

Write-Output $DSTs
}

#20110617 cmonahan- removed filters for "CLD" and "TRX"
#20110629 cmonahan- filtering out BED-PR-31 and BED-PR-32, reserved for mongodb VMs
