Hi Friends,
It was a tough time to find the PowerShell or a C# API to enable or disable Rating/Likes Settings in SharePoint 2013. I found a helpful post from Nanddeep for c# equivalent. I have converted it in PowerShell, hope this will help some of SharePoint developers and admins.
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue.
- $web=Get-SPWeb "http://abc.com/test";
- $list=$web.Lists["Pages"];
- if($list -ne $null)
- {
- Write-Host $list.Title "not null";
- $assembly=[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
- $reputationHelper =$assembly.GetType("Microsoft.SharePoint.Portal.ReputationHelper");
-
- $bindings = @("EnableReputation", "NonPublic", "Static");
- [System.Reflection.BindingFlags]$flags = [System.Reflection.BindingFlags]::Static -bor [System.Reflection.BindingFlags]::NonPublic;
-
- $methodInfo = $reputationHelper.GetMethod("EnableReputation", $flags);
-
- #For enabling Ratings
- $values = @($list, "Ratings", $false);
-
- #OR for enabling Likes
- #$values = @($list, "Likes", $false);
-
- $methodInfo.Invoke($null, @($values));
-
- #For disable Rating or Likes
- <#$methodInfo = $reputationHelper.GetMethod("DisableReputation", $flags);
- $disableValues = @($list);
- $methodInfo.Invoke($null, @($disableValues));#>
- }