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

Re: Unable to get Datastore name

$
0
0

You only seem to select the Name property, while you use the FreespaceGB property as well later on.

Try like this

 

$intNewVMDiskSize='250'

 

$oDatastoreWithMostFree=Get-Cluster MyClus |

    Get-Datastore|

    where{$_.Name-NotMatch'^datastore1|^Datastore123|^MyDatastore3|^datastore_udev'}|

    Sort-Object-Property {$_.FreeSpaceGB}-Descending:$true|

    Select-Object-First 1

  

if(($oDatastoreWithMostFree.FreespaceGB+100)-lt$intNewVMDiskSize){

    $($oDatastoreWithMostFree.Name)

}

else{

    "oh, no -- not enough freespace on datastore '$($oDatastoreWithMostFree.Name)' to provision new VM"

    return

}


Viewing all articles
Browse latest Browse all 251313

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>