How to Unfollow all the sites with powershell script at sharepoint 2013

​If you are looking to script the unfollowing of the sites in SP 2013 then you can use the following PowerShell. You can loop through users to execute the following code. For this sample I have hard coded User Name and Site URL.

$userName = "Contoso\brianc" 

$site = Get-SPSite "http://intranet.contoso.com"

$serviceContext = Get-SPServiceContext($site)

$profileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)

if($profileManager.UserExists($userName))
{
     $userProfile = $profileManager.GetUserProfile($userName)
    
     $followingManager = new-object Microsoft.Office.Server.Social.SPSocialFollowingManager($userProfile, $serviceContext)
     
     $followed = $followingManager.GetFollowed("Sites")
     
    $actorInfo = new-object Microsoft.Office.Server.Social.SPSocialActorInfo
    
     foreach($site in $followed)
    {        
        $actorInfo.ContentUri = $site.Uri
        $actorInfo.AccountName = $userProfile.AccountName
        $actorInfo.ActorType = "Site"
        $followingManager.StopFollowing($actorInfo)
    }

}​

SharePoint Saturday Ottawa – 2013

Last Saturday, on November 23rd, I presented at the SharePoint Saturday Ottawa​ 2013.
I presented a session in the developer track on Creating SharePoint 2013 workflow using Visual Studio 2012. It was a very well organized event in terms of planning, venue, food (:)) and prizes. They even gave swags to all the speaker.
I would like to thank everyone who attended my session. Please find my presentation slides below.
Kudos to all the organisors, sponsors and volunteers for successful event!!!

Slides from SharePoint Saturday Toronto – 2013

Last Saturday, on July 20th, I presented at the SharePoint Saturday Toronto 2013.
sharepointsaturdaytoronto.jpg
I presented a session in the developer track on What’s new in SharePoint 2013 workflow. It was a very well organized event in terms of planning, venue, food (:)) and prizes for many attendees. There was also a twitter competition. So all and all it was fun.
I would like to thank everyone who attended my session. Please find my presentation slides below.
Kudos to all the organisors, sponsors and volunteers for successful event!!!

Set Default value for Year column on your NewForm.aspx using Jquery

Sometimes when adding an item to your list or library you may want some of the metadata have default value selected. Today I am going to provide a quick tip on how you can set your Year column (textbox or dropdown) defaulted to current year value using Jquery.

<script language=”javascript” type=”text/javascript” 

src=”/Style Library/jquery-1.9.0.min.js”></script>

    <script language=”javascript” type=”text/javascript”>
    $(document).ready(function() {
     
    var currentYear = (new Date).getFullYear();

    // For Textbox  (change title value to your column title)
   
    $(“input[Title=’Year’]”).val(currentYear);
   
    // For dropdown(change title value to your column title)
   
    $(“select[Title=’Year’]”).val(currentYear).attr(“selected”, “selected”);
     
    });
</script>

Checking Task Status in SharePoint 2010 Workflow

This question comes up quite often. If you are building a SharePoint workflow (either Sequential or StateMachine) using Visual Studio 2010 and if you sometime want to check the status of your task using code then you can simply use the following code to achieve that.

TaskAfterProperties.ExtendedProperties
                    [SPBuiltInFieldId.TaskStatus].ToString()

The above code runs OnTaskChange Activity and uses Task AfterProperteis to get the Task Status.

Pretty Simple !!!