Fixes to Get-HVDatastore() when multiple datastores are specified
`$Datastores` needs to be initialized as an empty array `@()` rather than `$null`. Furthermore, if `$DsStroageOvercommit` is empty it is only initialised with a single element where there should be one element per datastore. I've moved the test into the loop instead.
This commit is contained in:
@@ -5039,15 +5039,16 @@ function Get-HVDatastore {
|
|||||||
foreach ($ds in $datastoreNames) {
|
foreach ($ds in $datastoreNames) {
|
||||||
$datastoresSelected += ($datastoreInfoList | Where-Object { ($_.DatastoreData.Path -eq $ds) -or ($_.datastoredata.name -eq $ds) }).id
|
$datastoresSelected += ($datastoreInfoList | Where-Object { ($_.DatastoreData.Path -eq $ds) -or ($_.datastoredata.name -eq $ds) }).id
|
||||||
}
|
}
|
||||||
$Datastores = $null
|
$Datastores = @()
|
||||||
if (! $DsStorageOvercommit) {
|
|
||||||
$DsStorageOvercommit += 'UNBOUNDED'
|
|
||||||
}
|
|
||||||
$StorageOvercommitCnt = 0
|
$StorageOvercommitCnt = 0
|
||||||
foreach ($ds in $datastoresSelected) {
|
foreach ($ds in $datastoresSelected) {
|
||||||
$myDatastores = New-Object VMware.Hv.DesktopVirtualCenterDatastoreSettings
|
$myDatastores = New-Object VMware.Hv.DesktopVirtualCenterDatastoreSettings
|
||||||
$myDatastores.Datastore = $ds
|
$myDatastores.Datastore = $ds
|
||||||
|
if (! $DsStorageOvercommit) {
|
||||||
|
$mydatastores.StorageOvercommit = 'UNBOUNDED'
|
||||||
|
} else {
|
||||||
$mydatastores.StorageOvercommit = $DsStorageOvercommit[$StorageOvercommitCnt]
|
$mydatastores.StorageOvercommit = $DsStorageOvercommit[$StorageOvercommitCnt]
|
||||||
|
}
|
||||||
$Datastores += $myDatastores
|
$Datastores += $myDatastores
|
||||||
$StorageOvercommitCnt++
|
$StorageOvercommitCnt++
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user