PoshCode Archive  Artifact [307e3ad1c2]

Artifact 307e3ad1c2f392420dfc69b17a0260b43384a49ea445dca5039c544bb502d70d:

  • File Get-mDatastoreList.ps1 — part of check-in [efee04ebc2] at 2018-06-10 13:27:01 on branch trunk — 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. (user: monahancj size: 1737)

# 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