Friday, January 8, 2016

Enable rating/like through powershell


Function EnableRating($web, $listName)
{
    $list=$web.Lists[$listName];
    if($list -ne $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));
    }
}

How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...