Skip to main content


Showing posts from July, 2013

PowerShell Command to Export Sub Site

Export site with these option. This will include all customizations, user securities, list & libraries etc.
Export-SPWeb -Identity http://sharepoint-demo/IC -Path "c:\bkup\IC.cmp" -Force -IncludeUserSecurity -IncludeVersions All

Note : ·http://sharepoint-demo/IC : You can change this site url. Put url of site which is going to be backed up. ·C:\backup\IC.cmp : You can change backup path with file name. You have to keep extention .cmp as it is.

More information about “Export-SPWeb”

What is Managed Path in SharePoint

Let’s understand what is path first. In SharePoint you have seen some different types of site collection urls within same Web Application like : ·http://sharepointDemo ·http://sharepointDemo/subsite ·http://sharePointDemo/Subsite/SubSubsite ·http://SharePointDemo/Sites/Contoso ·http://SharePointDemo/Sites/Contoso/SubSite

These different kind of URL structure called path & you can manage these path as per you your organization hierarchy or architecture. Some time you required to create a site collection with name of “Departments” & under this “Department” you might want to create some departments like HR, IT etc. and you want your site collection url should be like http://SharePointDemo/Departments/HR.
Managed path is this. Where you can manage site collection path not whole url. Here you can Manage Path for the selected Web Application.
In other words, when you creates your first site collection in Web Application you have to provide site collection url under section “Web Site Address…

Get web.config file in timer job

I was working on timer job & wanted to get data from sql server. To achive this goal, I add my database connection string in web application’s web.config file.
Now I used the following code to get web.config setting from timer job :
private string getConnectionString()         {             return System.Configuration.ConfigurationManager.AppSettings["MyAppSettingKey"];        }
But this code was not able to get the web.config file.
I started some R & D on it & found that Time Job runs under OWSTimer.exe & Web Application runs under W3WP.exe. As the context of  Both are different so we have to use WebConfigurationManager to get specific SharePoint Web Application configuration.
private string getConnectionString(string webAppName)         {             System.Configuration.Configuration webConfiguration = WebConfigurationManager.OpenWebConfiguration("/", webAppName);
            return webConfiguration.AppSettings.Settings["MyAppSettingKey "].…