Sunday, December 1, 2013

The term 'Select-Object' is not recognized as Name of a cmdlet

Hi friends,
This error usually occurs in SharePoint 2013 while running SharePoint 2013 Management Powershell.



This happens due to change in environment variable of “PSModulePath” in windows environment variables
To make it workable you need to perform following actions:
è Log in to the SharePoint Server
è Right click on my computer-> Properties-> Advance System Settings -> Environment Variable
è Scroll your System Variable section-> (PSModulePath) you will find below entry in Variable Value section 
ð  PS Module path:
;c:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules
è append below path in seme line:
;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
è It should look like below:
;c:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
 That’s it, now run SharePoint 2013 management shell as administration and you will not see the error

Happy Configuration.....






Saturday, August 24, 2013

Creating Custom Log Out page in SharePoint 2010/ 2013.

Hi friends,
This post is about how to create Custom Log out page in SharePoint. This customization is required when you implement FBA ( Form Based Authentication) or Mix mode authentication in SharePoint. When FBA is implemented with custom Log-in, it does not clear authentication Cookies automatically so to clear authentication cookies we need to do some customization. This customization is done using custom logout page where some block of java-script code is written:

This block of code also helps to prevent error while logging out using FBA.

Following steps are carried out while creating custom log out page in SharePoint with

1.       First Create a logout.aspx using SharePoint Designer
è Open your site using SharePoint designer-> Go to site pages->click on Page button on top ribbon and select ASPX page.
è It will create an aspx page in site pages rename it to Logout.aspx
è Double click on page, it will open page designer, Check Out the page and click on edit file link to open in edit mode.
è Add page title to: Lout out
è Add bellow Script in <head> section:
<script type="text/javascript">
function LogOutBodyOnLoad()
{
try
{
   /* Note : this command is support with only IE  */
  document.execCommand("ClearAuthenticationCache",false);
  window.close(); // It asks to close browser after logout.
  }
  catch (e) { }
 window.location='/_layouts/signout.aspx'; // Redirects to sign out page of SharePoint.
 }
 </script>
è In <body> section change as bellow:
<body onload="LogOutBodyOnLoad ()">
è Check in your Logout.aspx page after performing above changes.
è Next you need to call this Logout.aspx on click of Log out button on Welcom.aspx page that is master page of your site.
è Before change master page you need to check which master page is used by your application to check it go to Site Action->Site setting-Look and feel->Master page. It will show you which master page is used in your application.
è Go to SharePoint Designer -> click on master page in left navigation -> take copy of your master page. If you are working in SharePoint 2013 then you will get ( oslo.htm, oslo.master, seattle.html and seattle.master). Open only ( .html) page in designer and add below script on head section of master page which your application is using. ( check out your master page before editing )
<script type="text/javascript" src="/_catalogs/Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript" >
$(document).ready(function(){$("#zz4_ID_Logout").attr("onMenuClick","STSNavigate2(event,'/Site Pages/Logout.aspx');");});
</script>
è Add jquery fie to _catelogs/Scripts using SharePoint designer. If script folder does not exist in _catelogs crate it and add jqury file in it. Check proper version of jquery file with the master page tag.  Jquery file is added in _catelogs using SharePoint designer.
è If you are using SharePoint designer then Id of Logout control may be different, it may be zz3_ID_Logout or zz4_ …. So to get right ID login to your portal and check Source of page, Search for Log out and get right control ID. Replace control ID in Master page’ javascript tag with the right one.


è That’s it now you can login in to your portal and can identify title of log out page after clicking log out button. This could is mainly written to clear authentication cookies after logout.

That's it.. Fell free to ask any question regarding this post.

Happy Coding 
Regards
Gireesh Painuly..

Sunday, June 9, 2013

Save Site as Template is not visible in Site Settings in SharePoint 


Hi Friends,

This blog is about enabling “Save as Site Template” in SharePoint 2010 and SharePoint 2013.
Save Site as Template is only visible if you have publishing infrastructure disable in your site collection Administrator and site Action.
By default “save site as Template” is visible in Site Settings under <Site Action > In SharePoint 2010 and SharePoint 2013

SharePoint 2013









SharePoint 2010










If “Save as Site Template” is not visible in your Site actions perform following Actions:
1-> First go to your Site settings
  è Site Action -> Manage Site features Click on SharePoint Server Publishing and deactivate it if it is  enabled.
     2-> Site Collection Administrator -> Site Collection Feature (Deactivate following Feature)
  è Cross-Site Collection Publishing    ( optional)  
  è SharePoint Server Publishing Infrastructure
    3-> If you had publishing feature enabled and you have just deactivated it then you will not able to see Save as Site Template after deactivating publishing infrastructure. 
    4-> You need to open your site using SharePoint designer. After opening site using SharePoint designer just go to Site Tab, Site Option button on the right most part of panel, Click on it, a window will open as bellow:





















Happy Codding...

Thanks For Reading....

Gireesh Painuly.


Related Search: 

Enable Save Site as Template in SharePoint 2010
Enable Site as Template in SharePoint 2010.
Site as Template is not visible in Site Settings
Site as Template is not visible in Site Collection  
Site as Template is not visible in Site Action
Save Site as Template Option is Missing in SharePoint 2010.









Wednesday, March 27, 2013

Migrating Asp.Net Application to SharePoint 2010

Migrating Asp.Net Application to SharePoint 2010
Or
Converting asp.net 3.5 Web Application to SharePoint 2010

Hi Friends,
                     This blog is about converting or migrating custom asp.net 3.5 or 4.0 web application to SharePoint 2010.
Scenario: I have an application which was developed in asp.net 3.5 with sql server database. I have a SharePoint Portal where I need to deploy my Asp.net Web application. The main aim is to integrate all the asp.net application that were developed in Asp.net so that all the application can be access using single-sign-on and all application will have single access point in SharePoint.

Solution:  To accomplish this scenario I have first created a SharePoint site collection in a web application then in this web application I have created no of sub sites for each asp.net Web Application so that each application can be separated.

So Steps will as below:

Note: This solution is targeted to SharePoint 2010.
Step 1: Create a Web Application (if you don’t have existing one) from SharePoint Central administrator.

Step 2: Create a Site collection which will be the main entry point for SharePoint Portal.

Step 3: Create sub sites for each web application which you are planning to deploy in SharePoint so that you can link each application from main site.
 -  Now first check your existing asp.net Web application setting and configuration

Step 1:  Go to your Asp.net Web application and check if all the application are using .NET framework 3.5

Step 2: Go to all the application’s (if you have n-tier application) and check that every solution is using .net 3.5 framework.

Step 3: First Create strong key name for all the application dlls which you will copy to SharePoint so every solution in an application require strong key.

  ->  To generate strong key go to Start-> Visual studio 2010(2008)-> Tools -> Visual studio command Prompt. It will open visual studio command prompt.
  -> Type :  sn –k yourdllName.dll  <path of your snk file where you will like to store>
  ->  eg: sn –k mydll.dll C:\mysnk1.snk

Step 4: Now go to your asp.net application select solution one by one ->Project Properties. You will get signing tab click on it. Check sign the assembly checkbox and upload strong key and save.

Step 5: Follow same steps 3 to 4 for all your application to sign with strong key name.

Step 6: Add following line in all the assembly.cs of all layers ( if n-tier): at the top of [assembly attribute]. It allows SharePoint to call these dlls and also allows communication among dlls.

[assembly: System.Security.AllowPartiallyTrustedCallers]

Step 6: Now compile all of your dlls layer by layer and the complete solution.

Step 7: Next you need to copy all the dlls from you asp.net solutions’ bin directory to SharePoint. So you have created a SharePoint Site go to It’s virtual directory.

    -:  If your IIS is installed in C:\ drive then your path may look like below:
    -:  C:\inetpub\wss\VirtualDirectories\8888\bin where 8888 is the port number of my sharepoint site.
    -:  Copy all the dlls to Bin directory

Step 8: Next Open the web.config of your SharePoint portal which will be at your port no 8888 (your port no may differ).
   ->  Add following Tag to web.config file:

<!–Page parser added–>
<PageParserPaths>
<PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />
</PageParserPaths>


  ->  Mostly  <PageParserpaths> tag will be there in your web.config file search for it and place above tag in side it.
  ->  Next  you need to register your dlls within safe control section of web.config file go to <SafeControl> section and just press enter , then register your dll one by one here eg below

  <SafeControl Assembly="SPMigration, Version=1.0.0.0, Culture=neutral, PublicKeyToken= 512e23e28e25b338 " Namespace="SPMigration" TypeName="*" Safe="True" SafeAgainstScript="True"/>

      <SafeControl Assembly="BusinessLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken= f371028fb11feba8 " Namespace=" BusinessLayer " TypeName="*" Safe="True" SafeAgainstScript="True"/>

     - Assembly: Name of your assembly which you have copied in bin directory of SharePoint.

     -  Version: It will mostly 1.0.0.0 but you can check version of your assembly and replace it with correct version.

     - PublicKeyToken: You need to get public key token of your assembly, you can get it by using sn –T <your dll name>. It will display public key token copy it here.

     - NameSpace: It should contain name space which is written in side assembly some time assembly name and namespace is different. So check name space from your asp.net Web application and copy here.

   - Other attribute will remain same as I have written above.
Step 9: If your application contains database connection or any other dll registration which may be there in asp.net’s web.config file needs to be register here also in web.config file of SharePoint Portal. So copy connection string from your web.config to SharePoint portal config in Connection section of web.config same way register all dlls also in this config file.

Eg:
 <connectionStrings>
<add name=”MyCompanyConnectionString” connectionString=”Data Source=PRAVEEN;Initial Catalog=MyCompany;User ID=sa;Password=@System”
providerName=”System.Data.SqlClient” />
</connectionStrings>


Step 10: Now everything is in place, we need to copy our aspx pages in SharePoint site. For this go to your asp.net Application copy only aspx pages not .cs page in a separate folder on your computer.

   - Open your SharePoint site by using SharePoint designer and click on site pages. On top of ribbon bar click on import files and point to your local folder of where you have copied  aspx page. Click on ok button it will import all the aspx pages to SharePoint site page gallery.

 -  Now you need to change Master Page: Attach v4.Master page to these pages by going to Style tab on Ribbon, Click on Attach and select the v4.master as shown here. Select aspx page one by one and apply master page to them.

  -  Now go to source code of all your aspx pages one by one and remove codebehind tag.  

  -  Inheritance tag at tope of page is very important. It may struggle you to get data from your database. So don’t change it because we have registered our dll in web.config just make sure Inheritance=”DllName.CodebehindfileName”

   - If you want to use your master page of asp.net then you need not to use master page of SharePoint just keep the things as it is and put your master page in a web part which is used to display page content and it will work fine.

  -  Now  go to your SharePoint portal (or even you can check your pages in SharePoint designer by browsing page in browser), go to Site pages and click on any page which belongs to your application. You can see it has same look and feel as SharePoint.

That’s It your application is migrated now you can use Authentication of SharePoint and you can also use default permission of SharePoint with your aspx pages.

Note: If you get any issue regarding migration of your asp.net application write your comments or you can mail me at: girish.eng@gmail.com

Related link: 
Migrating asp.net web Application to ShaerPoint 2010
Converting asp.net Web Application to ShaerPoint 2010
Converting Custom asp.net Web Application to SharePoint 2010

Thanks & Regards
Gireesh Painuly
Happy Coding…


Saturday, March 23, 2013

How to Create Event Receiver in SharePoint 2010


Hi friends,
                  This is very small post about Event receiver in SharePoint. When we create event receiver we have lot of options to select which type of event receiver we want to create. We can create event receiver for SharePoint site, List and libraries and workflow.  Here I am mostly focusing on different list template id and how can we trigger an event for a particular list and library.
To create event receiver we need to perform following steps:  
 è Select SharePoint Project template->2010->Event receiver. Type proper name for event receiver and select .net framework 3.5 because SharePoint 2010 is built on top off .NET framework 3.5.


     è Type your Site Url and select deploy as sandbox solution



 è Here we have different types of event receiver as shown bellow. We can create event receiver for List Events, List Item Events, List Email Events, Web Events and List workflow events.



 è If we want to create list type event receiver then we have many set of events related to SharePoint List. Bellow are list of events related to SharePoint list.

 è If you select”List Item Events” then you have another options available which shows about the event source. Below are many event source list such as custom list, announcement list, contact list etc..

 è If you select “list Email Events” then you can send mail to user when any operation is performed on list. Here also we have event source and some events related to source.
       
 è If you select “Web Event” type event then you have only event related to web.
      
 è Here we will create List Item events and we will chose Custom List as event receiver and select related events which needed.
          
è You can check that It shows ListTemplateId=”100” based on different event source SharePoint has fixed ListTemplateId for each.

   

 è Now suppose we want to execute this event receiver to a particular list which is type of custom list we can set ListUrl of that list as show below
      
 è As shown below this event receiver will execute only for list MyListName. Like this way we can execute event receiver for any document library and web site.

è If you changed name of your event receiver from solution explorer then you also need to change tags inside Element.xml file otherwise event will not fire for event receiver. So wherever EventReceiver1 exist in Element.xml change it with your new name.

Types of Event in Event Receiver:
 è Before Events (Synchronous): The before events are those that happen just after the event occurred, but before SharePoint writes any data to the SharePoint content database. Such events are useful for custom validation, rules checking, and cancellation of users’ actions.
 è After Events (Asynchronous): The After events are those that happen after SharePoint commits the data to the SharePoint content database. These “After” event handlers cannot cancel the current action/operation, but they are guaranteed to execute only after specific actions.

 Before events run in the same process and thread as the current action, while After events by default run in a background thread; however, you can force them to run synchronously, that means within the same process and thread of the current action.

 è Below list shows ListTemplateId for all SharePoint list and libraries.
     
ListTemplateId
Description
100
Generic list
101
Document library
102
Survey
103
Links List
104
Announcement list
105
Contact List
106
Event List
107
Task List
108
Discussion Board
109
Picture Library
110
Data Source
111
Site Template Gallery
112
User Information List
113
Web Part Gallery
114
List Template Gallery
115
Xml Form Library
116
Master page Gallery
117
No-Code Workflows
118
Custom Workflow Process
119
Wiki Page Library
120
Custom Grid for list
130
Data Connection Library
140
Workflow History
150
Gantt Tasks list
200
Meeting Series list
201
Meeting Agenda list
202
Meeting Attendees list
204
Meeting Decisions list
207
Meeting Objectives list
210
Meeting text box
211
Meeting Things To Bring list
212
Meeting Workspace Pages list
300
Portal Sites list
301
Blog Posts list
302
Blog Comments list
303
Blog Categories list
1100
Issue tracking
1200
Administrator tasks list
2002
Personal document library
2003
Private document library

è You can select or type any one of the template Id in your event receiver to work for template specific.

This post is also related to:
How to create list specific Event receiver in SharePoint
Different List Template Id in SharePoint 2010
SharePoint List , Document library and Internal Id 

Regards 
Gireesh Painuly

Happy Coding ...