<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Abhinav Sobti’s blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/sobtiabhinav/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/sobtiabhinav/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:43:00 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Programmatically get Navigation Settings in SharePoint Server 2010 and 2013</title>
      <link>https://docs.microsoft.com/archive/blogs/sobtiabhinav/programmatically-get-navigation-settings-in-sharepoint-server-2010-and-2013</link>
      <pubDate>Mon, 28 Mar 2016 01:20:28 GMT</pubDate>
      <dc:creator><![CDATA[Abhinav Sobti]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sobtiabhinav/?p=44</guid>
      <description><![CDATA[While writing some custom SharePoint Web Services (asmx) in a project, I encountered a situation...]]></description>
      <content:encoded><![CDATA[While writing some custom SharePoint Web Services (asmx) in a project, I encountered a situation where I needed to fetch the Navigation Settings of the current subsite and the site collection. After lots of head scratching and searching online, I found out the below pieces of code useful in getting the navigation properties for SharePoint Server 2010 and 2013.

You must include the <em>Microsoft.SharePoint.Publishing</em> namespace.

Note : The following applies only to SharePoint sites with publishing features enabled. Other properties can be found in the SPWeb.Navigation (web.Navigation) object however.
<pre style="padding-left: 30px">using (SPSite site = new SPSite("https://yourweburl/"))
{
    using (SPWeb web = site.OpenWeb())
    {
        var publishingWeb = PublishingWeb.GetPublishingWeb(web);
        navSettings = new NavigationSettings // My Custom Model
        {
            Name = publishingWeb.Name,
            IncludePagesInCurrentNavigation = publishingWeb.Navigation.CurrentIncludePages,
            IncludePagesInGlobalNavigation = publishingWeb.Navigation.GlobalIncludePages,
            IncludeSubSitesInCurrentNavigation = publishingWeb.Navigation.CurrentIncludeSubSites,
            IncludeSubSitesInGlobalNavigation = publishingWeb.Navigation.GlobalIncludeSubSites,
            InheritCurrentNavigation = publishingWeb.Navigation.InheritCurrent,
            InheritGlobalNavigation = publishingWeb.Navigation.InheritGlobal,
            QuickLaunchEnabled = publishingWeb.Web.QuickLaunchEnabled,
            TreeViewEnabled = publishingWeb.Web.TreeViewEnabled
        };
   }
}</pre>
Useful, isn't it? You can try setting them as well using the Update() methods after assigning desired value to each of the properties to save changes to the navigation properties.]]></content:encoded>
    </item>
    <item>
      <title>Clear Excel cells using Windows PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/sobtiabhinav/clear-excel-cells-using-windows-powershell</link>
      <pubDate>Thu, 11 Feb 2016 03:16:28 GMT</pubDate>
      <dc:creator><![CDATA[Abhinav Sobti]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sobtiabhinav/?p=13</guid>
      <description><![CDATA[This will guide you how to use Microsoft PowerShell to clear cells in an Excel...]]></description>
      <content:encoded><![CDATA[This will guide you how to use Microsoft PowerShell to clear cells in an Excel worksheet.

&nbsp;

Loading the Excel file from your location :
<pre style="padding-left: 30px">#####################################################################
 ## Load Excel file
 $ExcelPath = 'D:\MyInputFile.xlsx'
 $Excel = New-Object -ComObject Excel.Application
 $Excel.Visible = $false
 $ExcelWorkBook = $Excel.Workbooks.Open($ExcelPath)
 $ExcelWorkSheet = $Excel.WorkSheets.item('MySheetName')</pre>
Writing the clearing logic with the help of nested For loops for rows and columns :
<pre style="padding-left: 30px">#####################################################################
 ## Clear Logic
 $RowMax = ($ExcelWorkSheet.UsedRange.Rows).count        ## get the total count of used rows
 for($i=2; $i -le $RowMax; $i++)         ## skip the header
 {
        for($j=2;$j -le 12;$j++)
        {
                $ExcelWorkSheet.Cells.Item($i, $j).clear()
        }
 }</pre>
Saving and closing all connections to Excel :
<pre style="padding-left: 30px">#####################################################################
 # Close connections to Excel
 $Excel.DisplayAlerts = $false
 $Excel.ScreenUpdating = $false
 $Excel.Visible = $false
 $Excel.UserControl = $false
 $Excel.Interactive = $false        ## set interactive to false so no save buttons are shown
 $Excel.ActiveWorkbook.Save()        ## save the workbook
 $Excel.ActiveWorkbook.Close()        ## quit the workbook
 $Excel.Quit()</pre>
Clearing the object references is always a good idea. You can use the following snippet to do so :
<pre style="padding-left: 30px">#####################################################################
## Close all object references
 Release-Ref($ExcelWorkSheet)
 Release-Ref($ExcelWorkBook)
 Release-Ref($Excel)</pre>
<pre style="padding-left: 30px">## Function to close all com objects
 function Release-Ref ($ref)
 {
        ([System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$ref) -gt 0)
        [System.GC]::Collect()
        [System.GC]::WaitForPendingFinalizers()
 }</pre>
Sample Input :

<a href="https://msdnshared.blob.core.windows.net/media/2016/02/SampleInput.png"><img class="alignnone size-full wp-image-23" src="https://msdnshared.blob.core.windows.net/media/2016/02/SampleInput.png" alt="SampleInput" width="476" height="209" /></a>

&nbsp;

Sample Output :

<a href="https://msdnshared.blob.core.windows.net/media/2016/02/SampleOutput.png"><img class="alignnone size-full wp-image-31" src="https://msdnshared.blob.core.windows.net/media/2016/02/SampleOutput.png" alt="SampleOutput" width="475" height="208" />
</a>

Complete Script can be downloaded <a title="ClearExcelCells.ps1" href="https://1drv.ms/1nZDkjs" target="_blank">here</a>.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Babysteps into the SharePoint World!</title>
      <link>https://docs.microsoft.com/archive/blogs/sobtiabhinav/hello-world</link>
      <pubDate>Fri, 22 Jan 2016 18:53:44 GMT</pubDate>
      <dc:creator><![CDATA[Abhinav Sobti]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sobtiabhinav/?p=1</guid>
      <description><![CDATA[I recently joined Microsoft as an Associate Consultant in Microsoft Services India Global Delivery -...]]></description>
      <content:encoded><![CDATA[I recently joined Microsoft as an Associate Consultant in Microsoft Services India Global Delivery - Business Productivity. I shall be working as a SharePoint Consultant here.

I'll keep posting blogs as I enter the SharePoint World which might be helpful for people who're very new to SharePoint.]]></content:encoded>
    </item>
  </channel>
</rss>