Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 230200

Re: Select Random Datastore

$
0
0

If you have a vSphere Enterprise Plus license I would use Datastore Clusters and I would deploy a VM to a Datastore Cluster. The Datastore Cluster will select the optimal datastore based on capacity and I/O load.

Otherwise you can use the following PowerCLI script to select a random datastore:

 

Get-datastore |

Where-Object {$_.Name -like "*NFS*" -and $_.FreeSpaceMB -gt ($_.CapacityMB * 0.25)} |

Get-Random -Count 1

 

If you want to select the datastore that has the most free space then you can use:

 

Get-datastore |

Where-Object {$_.Name -like "*NFS*" -and $_.FreeSpaceMB -gt ($_.CapacityMB * 0.25)} |

Sort-Object -Property FreeSpaceMB -Descending |

Select-Object -First 1

 

Message was edited by: Robert van den Nieuwendijk Added the second example.


Viewing all articles
Browse latest Browse all 230200

Trending Articles