Using this as a starting block.
VMware View 5.2 Documentation Library
I want to combine two functions, and have the variables use ".txt" files with my new and old datastores listed.
I've edited it a bit, combining the two functions, and creating variables for new and old lists, but I'm not sure on the context to provide to the variables for the text files. Any PowerShell / PowerCli guru's?
# A PowerShell function to add new, then remove old datastores from an automatic pool.
# UpdateDatastoresForAutomaticPool
# Parameters
# $Pool Pool ID of pool to be updated.
# $OldDatastore Full path to OldDatastore.txt to be removed.
# $NewDatastore Full path to NewDatastore.txt to be added.
$Pool = "C:\powercli\PersistentPools.txt"
$OldDatastore = "C:\powercli\OldDatastore.txt"
$NewDatastore = "C:\powercli\NewDatastore.txt"
function RemoveDatastoreFromAutomaticPool
{ param ($Pool, $OldDatastore)
$PoolSettings = (Get-Pool -pool_id $Pool)
$currentdatastores = $PoolSettings.datastorePaths
$datastores = ""
foreach ($path in $currentdatastores.split(";")){
if(-not ($path -eq $OldDatastore)){
$datastores = $datastores + "$path;"
}
}
Update-AutomaticPool -pool_id $Pool -datastorePaths $datastores
}
function AddDatastoreToAutomaticPool
{ param ($Pool, $NewDatastore)
$PoolSettings = (Get-Pool -pool_id $Pool)
$datastores = $PoolSettings.datastorePaths + ";$NewDatastore"
Update-AutomaticPool -pool_id $Pool -datastorePaths $datastores
}
Thanks,
-Matt