Showing posts with label sharepoint 2010. Show all posts
Showing posts with label sharepoint 2010. Show all posts

November 09, 2014

SharePoint Uninstall, Remove, Add, Install SPSolution .wsp using PowerShell or STSADM

This is gonna very often command that you will keep using to Add and Activate solution in SharePoint Environment so you can bookmark it or follow the blog.

Well the deployment process includes below set of steps to Remove and Add Solutions in SharePoint.
1.      Retract
2.      Remove
3.      Add
4.      Deploy

First Deactivate Solution then Remove Solution, then Add Solution from local drive and Activate to desired scope.

There are 3 simple ways to do so.
·        From SharePoint site, go deactivate then from CA retract and remove solution.
·        Second way is STSADM.exe
·        Third and most preferred way is PowerShell.

Uninstalling SharePoint wsp package using PowerShell command

Uninstall-SPSolution –Identity “MySolution.wsp” –WebApplication “WebApp Url”

Remove SharePoint wsp package using PowerShell command

Remove-SPSolution–Identity "MySolution.wsp"

Add SharePoint wsp package using PowerShell command

Add -SPSolution "C:\Praveen\MySolution.wsp"

Installing SharePoint wsp package using PowerShell command

Install-SPSolution –Identity "MySolution.wsp" –WebApplication "url" –GACDeployment

Using STSADM command

open command prompt and Go to path,
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN
 
Add Solution
stsadm.exe -o addsolution -filename "c:\Praveen\MySolution.wsp"
 
Deploy Solution
stsadm.exe -o deploysolution -name "MySolution.wsp" -url "http://server/" -allowgacdeployment -immediate

Activate feature
stsadm.exe -o activatefeature -name "MySolution.wsp" -url "http://server/"




--
Regards,
Praveen Pandit



September 07, 2014

Production Server maintance daily alert email using powershell, check free space

Well we have number of servers for productions so going to each server (WFE, DB, Application and DMZ servers) etc and checking for frees pace and running services etc that's really hectic and that it time consuming environment that may have 4WFE 2DB 1Application and 1DMZ server.

In short we should create task scheduler and run PowerShell script that can check for free space, running services and process etc... and send 1 email for all these details.

Here I am sharing sample script :
1) Production Server maintenance daily alert email using powershell:checking free space of C drive.



You can download above code to check free space, from here.



--
Thanks,
Praveen Pandit

June 08, 2014

PowerShell Create lookup, how to create cross site lookup in SharePoint

SharePoint  gives us an easy way to create lookup columns in same site (in developers language same Web ;) ) but some time we have to create lookup column between two different sites, well there is no direct option provided by Microsoft. But there is simple way to do it using PowerShell.

All you need to know is web/Site names and list names and executive below lines of code....


powershell CrossSite Lookup










You can download this piece of code here.



Thanks,
Praveen Pandit

December 22, 2013

Error: Cannot connect to the configuration database. ; getting error while hitting Windows SharePoint websites or Central Administrator



 Error "Cannot connect to the configuration database" when you connect to a Windows SharePoint websites or Central Administrator.





This problem occurs when you made some update on windows / install or uninstall  of MS products. You may have tried IISreset or server reboot but nothing worked. So lets try below point

1)    By looking at massage a school guy can say its unable to connect Sql Database. So first step is to check Sql services and try to start/restart and check.Refer Link for details.
Still that doesn’t work you can try below option
2)    Try to reconfigure Sql
 It may be Your configuration trying to connect to the DB via the wrong port. Ir may be incorrect configuration setting accounts and all. Or may be firewall rule blocking you. To resolve this you can do Configuration of DB by configuration wizard you can refer Link for details.
3)    Again this didn’t worked you it means your services and configuration is correct lets use some commands to do it work refer Link.
4)    Go to Sql management and give permission to account
5)    Or go to SQL server configuration manager change service account and try again by restarting/starting Sql services and again make old account and retry.


Don't forget to run with elevated privileges!


You can share your views, issue or findings below, on this.

--
Regards,
Praveen Pandit

September 09, 2013

SharePoint 2010 Collapsible Left navigation for Production / accordion menu using jQuery / javascript


This is one of the basic needs if you have large number of list and libraries.
An accordion type left navigation or you can say it collapsible left navigation using Jquery or JavaScript.
As an initial step me too goggled to get ready code for production so got below these links, I guess you also have visited them.


http://www.lookupdesign.com/sharepoint/2012/08/collapsible-quick-launch.html.

http://www.sharepointcolumn.com/collapsible-quicklaunch-menu-for-sharepoint2010-using-jquery/
http://css-tricks.com/forums/topic/sharepoint-quick-launch-collapsible-menu/
http://www.huedesigner.com/collapsible-quicklaunch-menu-for-sharepoint2010-using-jquery/

 

For me things are not expected and up to the mark to make it live on production.
Here are few of points that made you to use my JavaScript code.
 
1) Wants a well formatted collapsible menu.


2) If any header don’t have sub header so no collapsible option should enable to that header.


3) User should able to click on header to redirect respective page (collapsible option shouldn’t apply on header text click event.


4) After user click any sub heading so header should be selected as well except that header other should be collapsed (for that we need to use cookies).


5) Only one header at a time should be open other should be collapsed.


6) Obviously It should be cross browser compatible and should be user friendly.

Now how make it.

1) Go to site and open it in SharePoint 210 designer.

2) Select Master Pages (v4.master), check out and open in advanced edit mode.

3) Go to head section of Master page append below JavaScript code


<script type="text/javascript" src="http://ajax.Microsoft.com/ajax/jQuery/jquery-1.7.1.min.js">
</script>
<script type="text/javascript">
  
  function setCookie(c_name,value,expdays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + expdays);
    var c_value=escape(value) + ((expdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value+"; path=/";
  }
  
  function getCookie(c_name) {
    var c_value = document.cookie;
    var c_start = c_value.indexOf(" " + c_name + "=");
    if (c_start == -1) c_start = c_value.indexOf(c_name + "=");
    if (c_start == -1) c_value = null;
    else {
      c_start = c_value.indexOf("=", c_start) + 1;
      var c_end = c_value.indexOf(";", c_start);
      if (c_end == -1){
        c_end = c_value.length;
      }
      c_value = unescape(c_value.substring(c_start,c_end));
    }
    return c_value;
  }
  // starting main function
  $(function($) {
    
        //Hide all
  $('.s4-ql li ul').hide();
   var Expand = "/_layouts/images/plus.gif";
   var Collapse = "/_layouts/images/minus.gif"; 
  // Select saved Header from cookies
   var menuClickedOld1 = getCookie("HeaderName");

  // Adding margin to header those has no sub items.
  $('.s4-ql ul.root').find('li').each(function(index) {
   if($(this).find("ul").text()){}
   else{$(this).css("margin-left","13px");}  
  });
  // Adding Anchor tag and img to headers
  $('.s4-ql ul li').find('ul').each(function(index) {
  var $this = $(this);

//// Cookkies set updates need to update in Prodcution.
  if($(this).parent().find('a:first .menu-item-text').parent().parent().text() == menuClickedOld1){
   $this.parent().find('a:first .menu-item-text').parent().parent().parent().prepend([''].join(''));
  }
  else{
   $this.parent().find('a:first .menu-item-text').parent().parent().parent().prepend([''].join(''));
  }
  });
  //Setup Click Hanlder

   if(menuClickedOld1!=null && menuClickedOld1!=""){

  $('.s4-ql ul.root').find('li').each(function(index) {
  if($('li:contains('+menuClickedOld1+') ul span.ms-hidden').text() ==="Currently selected")
  {  
   //$(this).find(".spclick").attr('src',Collapse);
  }
 });

 $('li:contains('+menuClickedOld1+') ul').show();

 }  

  // Adding Bullets
   $(".s4-ql ul.root ul> li.static>a span span").prepend(' • ');


 // Set cookies to null if any header cliked that has no child.
  $(".s4-ql ul.root li a.static").click(function(){

  if($(this)[0].href.indexOf("_layouts") >0){

   setCookie("HeaderName","",1);
  }
 });
  

  $('.arrw').click(function() { 
   
   $(".s4-ql ul li a img").attr('src',Expand).attr('width','14');

   var v= $(this).parent().html();
   var lnName;
   if($.browser.msie){
    lnName=$(v.slice(0,v.indexOf('<UL'))).find("span span").text();
   }
   else{
    lnName=$(v.slice(0,v.indexOf("<ul"))).find("span span").text();
   }

// Cookkies clear if collaps/clicked on same header click.

   var menuClickedOld1 = getCookie("HeaderName");
   if(menuClickedOld1 != null && menuClickedOld1 != "")
   {
    if(menuClickedOld1 != lnName)
    {setCookie("HeaderName",lnName,1);}
    if(menuClickedOld1 == lnName)
    {setCookie("HeaderName","",1);}
   }else{setCookie("HeaderName",lnName,1);}

   //Get Reference to img
   var img = $(this).children();
   //Traverse the DOM to find the child UL node
   var subList = $(this).siblings('ul');
   //Check the visibility of the item and set the image
   var Visibility = subList.is(":visible");

   if(Visibility){
    img.attr('src',Expand);subList.hide('fast');}
   else{
     $('.s4-ql li ul').hide();
    img.attr('src',Collapse);subList.show('fast');}
  });
    
  }
   );
</script>


4) Check in MasterPage and Publish it.


5) Now clear you’re all cookies and Temporary saved file in your browser hit your site.




Please share any issue or findings on this.


--
Regards,
Praveen Pandit