下列 PowerShell 函數會使用 vSphere PowerCLI,傳回叢集中由資源集區指定之資料存放區的完整路徑。

# VVGetDatastorePath
# Parameters
#     $Datastore Datastore object in vSphere PowerCLI.
#     $ResourcePool Resource pool in cluster.
#
#Example
# 				VVGetDatastorePath (Get-Datastore "datastore1") (Get-ResourcePool "Resources")

function VVGetDatastorePath($Datastore,$ResourcePool){
    if($Datastore -and $ResourcePool){

        $dsType = $Datastore.GetType().Name
        $rpType = $ResourcePool.GetType().Name
        if(-not ($dsType.Contains("Datastore")) ){
            Write-Error "The Datastore provided is not a Datastore object."
            break
        }
        if(-not ($rpType.Contains("ResourcePool")) ){
            Write-Error "The Resource Pool provided is not a ResourcePool object."
            break
        }

        $ClusterPath = VVGetPath(Get-Inventory -Id $ResourcePool.ParentId)
        $path = $ClusterPath + "/" + $Datastore.Name
        $path
    }
}