Move and Resize BranchCache Hash/Data Cache on Distribution Point
This one is pretty self explanatory. If you use BranchCache by default it puts the caches on C: drive and you might find that your C: is the smallest drive (depending on your server configuration).
Anyways here is something that will help you move those caches around and set them to a different size.
#Check if cache already moved
$CacheStatus = Get-BCStatus
If(($CacheStatus.HashCache.CacheFileDirectoryPath -like 'E:\')-or($CacheStatus.DataCache.CacheFileDirectoryPath -like 'E:\'))
{
Set-BCDataCacheEntryMaxAge -TimeDays 10
Return "Already Moved"
}
elseif ((Get-Volume -DriveLetter E).FileSystem -ne "NTFS")
{
# Set Cache Sizes
get-bchashcache | set-bccache -Percentage 2 -Force -Confirm:$false
get-bcdatacache | set-bccache -Percentage 1 -Force -Confirm:$false
Set-BCDataCacheEntryMaxAge -TimeDays 10
Return "Destination Not NTFS"
}
else
{
#Create New Directories
$rootPath = "E:\data\BranchCache"
New-Item -Path $rootPath -ItemType Directory
"This is used to hold the caches for branchcache." | Out-File $rootPath\Readme.txt
$NewHashDirectory = $rootPath + "\Hash"
New-Item -Path $NewHashDirectory -ItemType Directory
$NewDataDirectory = $rootPath + "\Data"
New-Item -Path $NewDataDirectory -ItemType Directory
#Clear Caches
Clear-BCCache -Force -Confirm:$false
#Move Hash Cache
Set-BCCache -Path $CacheStatus.HashCache.CacheFileDirectoryPath -MoveTo $NewHashDirectory
#Data Cache
Set-BCCache -Path $CacheStatus.DataCache.CacheFileDirectoryPath -MoveTo $NewDataDirectory
# Set Cache Sizes
get-bchashcache | set-bccache -Percentage 20 -Force -Confirm:$false
get-bcdatacache | set-bccache -Percentage 2 -Force -Confirm:$false
Set-BCDataCacheEntryMaxAge -TimeDays 10
Return "Move Complete"
}
Anyways here is something that will help you move those caches around and set them to a different size.
#Check if cache already moved
$CacheStatus = Get-BCStatus
If(($CacheStatus.HashCache.CacheFileDirectoryPath -like 'E:\')-or($CacheStatus.DataCache.CacheFileDirectoryPath -like 'E:\'))
{
Set-BCDataCacheEntryMaxAge -TimeDays 10
Return "Already Moved"
}
elseif ((Get-Volume -DriveLetter E).FileSystem -ne "NTFS")
{
# Set Cache Sizes
get-bchashcache | set-bccache -Percentage 2 -Force -Confirm:$false
get-bcdatacache | set-bccache -Percentage 1 -Force -Confirm:$false
Set-BCDataCacheEntryMaxAge -TimeDays 10
Return "Destination Not NTFS"
}
else
{
#Create New Directories
$rootPath = "E:\data\BranchCache"
New-Item -Path $rootPath -ItemType Directory
"This is used to hold the caches for branchcache." | Out-File $rootPath\Readme.txt
$NewHashDirectory = $rootPath + "\Hash"
New-Item -Path $NewHashDirectory -ItemType Directory
$NewDataDirectory = $rootPath + "\Data"
New-Item -Path $NewDataDirectory -ItemType Directory
#Clear Caches
Clear-BCCache -Force -Confirm:$false
#Move Hash Cache
Set-BCCache -Path $CacheStatus.HashCache.CacheFileDirectoryPath -MoveTo $NewHashDirectory
#Data Cache
Set-BCCache -Path $CacheStatus.DataCache.CacheFileDirectoryPath -MoveTo $NewDataDirectory
# Set Cache Sizes
get-bchashcache | set-bccache -Percentage 20 -Force -Confirm:$false
get-bcdatacache | set-bccache -Percentage 2 -Force -Confirm:$false
Set-BCDataCacheEntryMaxAge -TimeDays 10
Return "Move Complete"
}
Comments
Post a Comment