Showing posts with label solution. Show all posts
Showing posts with label solution. Show all posts

Saturday, 10 September 2016

SharePoint solution wsp Deployment SPSolution using PowerShell or STSADM - Uninstall, Remove, Add, Install

You are looking to have some handy commands or camdlets so this is/was/will very often commands that you may keep using as SharePoint Admin and developer SharePoint Environment so you can bookmark this blog.
is/was/will... why was? actually if you are working on SharePoint Online. for on premise you will need to have these information. ;)

So the deployment process includes below set of steps for existing Solutions in SharePoint.
  1. Retract solution
  2. Remove wsp
  3. Add wsp
  4. Deploy soltion. 
For new Solution deployment you will perform above mentioned two steps 3 and 4.
  
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.
  1. From SharePoint site, go deactivate then from CA retract and remove solution.
  2. Second way is STSADM.exe
  3. Third and most preferred way is PowerShell.
Uninstalling wsp package using PowerShell command

Uninstall-SPSolution –Identity "MyWPSFile.wsp" –WebApplication "WebApp Url"

Remove wsp package using PowerShell command

Remove-SPSolution–Identity "MyWPSFile.wsp"

Add wsp package using PowerShell command

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

Installing SharePoint wsp package using PowerShell command

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

Installing SharePoint wsp at SharePoint 2013 version to deploy file at 15 hive and/or 14 hive, using PowerShell command


  • Uninstall-SPSolution SolutionName.wsp -AllWebApplications  #Solution deployed on AllWebApp
     
  • Remove-SPSolution SolutionName.wsp

    Add-SPSolution -LiteralPath "E:\Solutions\SolutionName.wsp"
     
  • Install-SPSolution -Identity SolutionName.wsp -GACDeployment -AllWebApplications -CompatibilityLevel "All" # You can mentioned 15 or 14 or both (All) to copy all files to 14 and 15 hive of your sharepoint 2013 version
     
  • Update-SPSolution also help you in same case.

Using STSADM command


open command prompt with Admin privileges and go to below 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/"


For bulk feature deployment or big releases we can plan sequence of wsp deployment and feature activation using PowerShell scripts and Configuration xml / csv or text files.


--
Thanks and let me know if needs any help


Thursday, 30 July 2015

Update Modified by and Created by in SharePoint list

Some of you have face the situation to update list with large number of items or some time we have to change, so that lead to change Modified By to your name; Modified or created by names of all items, yeah we are aware about System.Update() method but if data has populated and no code action will take place and requirement says to update because we don't wants to confuse client/Business users and his customers so in very rare and after approval we execute it to update modified and created by names.

We can use below script to update thousands of list items in single shot. but take care once changes are done by PowerShell can not be roll back. 

so to update SharePoint list items simply can save below PowerShell script in a .PS1 file and run it with Elevated privileges in SharePoint server where you has permission to modify items. 

PowerShell:


<# Created by: MakrShortWork
   Purpose:   To update Modified and created by Names.
   Created Date: June, 2011
#>

  $web = Get-SPWeb "http://YourWebUrl"
  $spList =  $web.Lists["ListName"]  
  $ListItemID = 23;
  $UserName =$ web.EnsureUser("domain\useridLoginId");  
     
  $caml = '<Where><Eq><FieldRef Name="ID" /><Value Type="Text">{0}</Value></Eq> </Where>' -f $ListItemID
  $query = new-object Microsoft.SharePoint.SPQuery
  $query.Query=$caml
  $oItem = $spList.GetItems($query)[0]

# in List Created by -Author and Modifed by -Editor
     $oItem["Author"] = $UserName           
     $oItem["Editor"] = $UserName  

     # You can add other fields here any field value data time etc....
     $oItem.Update()
    # You can use SystemUpdate(true/false);

Please run script on SharePoint server with Admin privileges,
Share or refer the link, that may help some one

-