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

August 07, 2014

How to Covert string to valid file name format, get valid file name, file name validation

This is general question that How to Covert string to a file name to save on drive or some location. our Keyboard have so many special characters and looking for more symbols in our keyboard,
That's good for users but for developers its headache coz out of those characters few are allowed in file name,
That makes issue sometime while reading/writing or creating file.

if user entered some incorrect word so instead of giving error to end user we can replace all those special characters by any specific character like I have done with char '_' underscore,
The file name is very important in terms of search or crawl files/file name.


So to make it simple, easy and working I have would prefer to use below way to do so.....


C# Code:
private string ConverToStandardFileName(string accountName)
        {
            foreach (char c in System.IO.Path.GetInvalidFileNameChars())
            {
                accountName = accountName.Replace(c, '_');
            }
            return accountName;
        }


That can be used in any aspx or C#/Windows appliaction. Other ways are also suggested over internet like .Replace("%","").Replace("&",""),Replace("*","") etc....


Other ways/suggestion are welcome, also shared you findings on this.


--

Regards,
Praveen Pandit
Keep Sharing Knowledge!!

August 04, 2014

JQuery tutorial, cookies, frequently used tags, javascript most used syntex, JQuery basics for professionals Part 3


Working with Cookies in jQuery using JQuery plugin and without plugin, or you can say using JavaScript only a traditional way.

<script src="/path/to/jquery.js"></script>
<script type="text/javascript" src="/path/to/jquery.cookie.js"></script>

$.cookie("UserAge", 43); // this will save 43 in you cookie named UserAge.


$.cookie("UserAge"); // will give cookie value = 43.


$.removeCookie("UserAge"); // cookie removed.


$.cookie("city", "Indore", {path: "/", domain: "abc.com"});
$.cookie("name", "Lap", {expires: new Date(2018, 12, 31, 11, 59, 00) }); // expire on specific date

Create expiring cookie, 7 days from then:
$.cookie('name', 'value', { expires: 7 });
Create expiring cookie, valid across entire site:
$.cookie('name', 'value', { expires: 7, path: '/' }); 
 
This article showed you how to manage cookies using jquery.cookie, a jQuery plugin. It solves many problems by abstracting cookie implementation details into a few simple, flexible methods. In case you need further clarification or additional examples, please refer to the official documentation.
 
Now other tradition way is,


var ck = getCookie("CookieName"); // get
setCookie("CookieName","value",1); // set



Code:
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;
 }


var windowWidth = $(window).width(); //retrieve current window width
  
var windowHeight = $(window).height(); //retrieve current window height


var documentWidth = $(document).width(); //retrieve current document width


var documentHeight = $(document).height(); //retrieve current document height


var vScrollPosition = $(document).scrollTop(); //retrieve the document scroll Top position


var hScrollPosition = $(document).scrollLeft(); //retrieve the document scroll Left position 


Blog Part 1 (Basics, Selectors and scroll bar)
Blog Part 2 (Get and set values of different elements)
Blog Part 3 (JavaScript windows code and Cookies) 



 
--
Regards,
Praveen Pandit

JQuery tutorial, Get set values,window,height,width frequently used tags, JQuery basics for professionals Part 2

We have seen basics of Jquery with sample code with short and easy examples in our Part 1 (JS Basics, Selectors and scroll bar). Now this is part 2, in this blog we will see how to select elements of different types and set and get values of them using JQuery. 



 // get value from text box  
  alert("Text : "+$("#myText").val());   
   
  // dropdown get selected value  
  alert("Selected : "+$("#MySelect :selected").val());  
         
  // get value from Textarea  
  alert("Text : "+$("#myTextArea").val());   
   
  // get value of check box  
  alert("Checked : "+$("[name='sex']:checked").val());   
   



and Sample Html is:
 <input name="foop" id="myText" type="text" value="Praveen" />   
   <select name="foo" id="MySelect" >  
     <option value="one">one</option>  
     <option value="two">two</option>  
     <option value="three">three</option>  
   </select>   
 <textarea name="foop" id="myTextArea" rows="2" cols="20" >Good blog for learning </textarea>  
   
 <input type="radio" name="sex" value="male" checked='true'>Male   
 <input type="radio" name="sex" value="female" >Female  


How to Set values in html controls or elements using Jquery,

 $('input[name="sex"][value="male"]').attr("checked", true); // checked value of radio box  
   
 $("#MySelect").val("three"); // dropdown value set  
   
 $("#myText").val("Praveen");// text box  
   




var windowWidth = $(window).width(); //retrieve current window width

var windowHeight = $(window).height(); //retrieve current window height

var documentWidth = $(document).width(); //retrieve current document width

var documentHeight = $(document).height(); //retrieve current document height

var vScrollPosition = $(document).scrollTop(); //retrieve the document scroll Top position

var hScrollPosition = $(document).scrollLeft(); //retrieve the document scroll Left position

Blog Part 1 (Basics, Selectors and scroll bar)
Blog Part 2 (Get and set values of different elements)
Blog Part 3 (JavaScript windows code and Cookies) 

 
--
Regards,
Praveen Pandit