Computer step by step
 Make your Pc better
Description:  

This policy enables a hash generation service to generate hashes for data stored in shared folders, and then
provide these hashes to client computers on which BranchCache is enabled. Hashes are
mathematically-derived digital fingerprints of files that uniquely identify the contents of files. These digital
fingerprints are very small, enabling Windows to compare files without consuming a significant amount of
Wide Area Network (WAN) bandwidth.

A client computer in a branch office can obtain a hash for a file across a WAN link if all of the following
conditions are true:      
1) The user has permissions to access the file.
2) BranchCache is enabled on the client computer.
3) Hash publication is permitted on the shared folder that the client computer is accessing.

If the client computer obtains the hash, the computer can then search for an identical version of the file in the
cache of other computers in the branch office. If Windows finds an identical version of the file in the branch
office, the client computer downloads the locally-cached copy instead of downloading the file across the
WAN link.

If you configure this policy to "Allow hash publication only for shared folders on which BranchCache is
enabled" (value = 0), hashes are generated only for shared folders on which BranchCache is enabled.
Hashes for these shared folders are generated when either of the following events occurs:
1) A file is accessed in a shared folder on which BranchCache is enabled by a client with BranchCache support
enabled.
2) An administrator manually generates hashes using the command-line tool Hashgen.

If you configure this policy to "Disallow hash publication on all shared folders" (value = 1), hashes are never
generated or provided by computers on which this policy is applied.

If you configure this policy to "Allow hash publication for all shared folders" (value = 2), hashes are generated
for all shared folders on the server when either of the following events occurs:
1) A file is accessed in a shared folder on the server by a client with BranchCache support enabled.
2) An administrator manually generates hashes using the command-line tool Hashgen.

Supported on: At least Windows 7 or Windows Server 2008 R2.
Hash Publication for BranchCache
Description Gpedit Regedit CMD Back VBScript PowerShell Script
Gpedit:   

Please perform the following steps:

Please go to Pearl button (Start) and click on the Search programs and files
For more information about the change from Start to Pearl button click here
Type gpedit.msc and press Enter
In the Group Policy window please navigate to Computer Configuration -> Administrative Templates ->
Network -> Lanman Server and open Hash Publication for BranchCache.
Not Configured -> is the Default state
Enabled -> apply this GPO
Disabled -> this GPO will not be applied

To finish press ok button and close Group Policy window.
Description Gpedit Regedit CMD Up Back VBScript
Type regedit and press ok
Please confirm User Account Control pop-up
Microsoft official disclaimer

Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by
using another method. These problems might require that you reinstall the operating system. Microsoft
cannot guarantee that these problems can be solved. Modify the registry at your own risk.

Note: This registry key is created by Group Policy when this GPO is Enable. The GPO Default state is Not
Configured -> this registry entry is not present. For Disable this registry entry is not present.

Please navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\LanmanServer
and locate HashPublicationForPeerCaching registry key
Regedit:          

Please perform the following steps:

Please go to Pearl button (Start) and click on the Search programs and files
For more information about the change from Start to Pearl button click here
Description Gpedit Regedit CMD Up Back VBScript
Double click on Hash Publication for BranchCache and edit the value:

To Enable:
Change the data value with:
Allow hash publication only for shared folders on which BranchCache is enabled = 0
Disallow hash publication on all shared folders = 1
Allow hash publication for all shared folder = 2
To finish press ok button and close Registry Editor window

Note: Manual editing of this registry key will not be reflected in Group Policy. If you modify this GPO from
Group Policy this registry key will be rewritten.
PowerShell Script PowerShell Script
   
   
Description Gpedit Regedit Back CMD VBScript Up
Type cmd, right click on cmd icon under the Programs and click on Run as administrator
Please confirm User Account Control pop-up
Please select, right and copy a registry key from below, then right click on command prompt window
, select Paste and press Enter

Enabled:
Allow hash publication only for shared folders on which BranchCache is enabled:
REG add "HKLM\SOFTWARE\Policies\Microsoft\Windows\LanmanServer" /v HashPublicationForPeerCaching /t REG_DWORD /d 0 /f
Disallow hash publication on all shared folders
REG add "HKLM\SOFTWARE\Policies\Microsoft\Windows\LanmanServer" /v HashPublicationForPeerCaching /t REG_DWORD /d 1 /f
Allow hash publication for all shared folder
REG add "HKLM\SOFTWARE\Policies\Microsoft\Windows\LanmanServer" /v HashPublicationForPeerCaching /t REG_DWORD /d 2 /f

Not Configured\Disabled:
REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows\LanmanServer" /v HashPublicationForPeerCaching /f

Note: Manual editing of this registry key will not be reflected in Group Policy. If you modify this GPO from
Group Policy this registry key will be rewritten.
CMD:          

Please perform the following steps:

Please go to Pearl button (Start) and click on the Search programs and files
For more information about the change from Start to Pearl button click here
PowerShell Script
   
Description Gpedit Regedit Back CMD VBScript Up
VBScript:          

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Policies\Microsoft\Windows\LanmanServer"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = "HashPublicationForPeerCaching"
'Enabled
'Allow hash publication only for shared folders on which BranchCache is enabled
dwValue1 = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue1
'Disallow hash publication on all shared folders
'dwValue2 = 1
'oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue2
'Allow hash publication for all shared folder
'dwValue3 = 2
'oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue3
'Not Configured
'oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName
PowerShell Script
   
Description Gpedit Regedit Back CMD VBScript Up
PowerShell Script :          

Enabled

$RegKey = "HKLM:\SOFTWARE\Policies\Microsoft\Windows"
If(Test-Path ($RegKey + "\LanmanServer"))
{
 $RegKey = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LanmanServer"
  ##Enabled
 ##Allow hash publication only for shared folders on which BranchCache is enabled
 New-ItemProperty -path $RegKey -name HashPublicationForPeerCaching -value 0 -PropertyType DWord -Force
 ##Disallow hash publication on all shared folders
 ##New-ItemProperty -path $RegKey -name HashPublicationForPeerCaching -value 1 -PropertyType DWord -Force
 ##Allow hash publication for all shared folder
 ##New-ItemProperty -path $RegKey -name HashPublicationForPeerCaching -value 2 -PropertyType DWord -Force
}
else
{
 New-Item -path $RegKey -name LanmanServer
 $RegKey = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LanmanServer"
  ##Enabled
 ##Allow hash publication only for shared folders on which BranchCache is enabled
 New-ItemProperty -path $RegKey -name HashPublicationForPeerCaching -value 0 -PropertyType DWord -Force
 ##Disallow hash publication on all shared folders
 ##New-ItemProperty -path $RegKey -name HashPublicationForPeerCaching -value 1 -PropertyType DWord -Force
 ##Allow hash publication for all shared folder
 ##New-ItemProperty -path $RegKey -name HashPublicationForPeerCaching -value 2 -PropertyType DWord -Force
}

Not Configured\Disabled

$RegKey = "HKLM:\SOFTWARE\Policies\Microsoft\Windows"
Remove-ItemProperty -Path($RegKey + "\LanmanServer") -name HashPublicationForPeerCaching
If( (Get-Item -Path($RegKey + "\LanmanServer")).ValueCount -eq 0 -and (Get-Item -Path($RegKey + "\LanmanServer")).SubKeyCount -eq 0)
{
 Remove-Item -Path($RegKey + "\LanmanServer")
}
Up Back PowerShell Script