Monday, 4 February 2013

STSADM vs. PowerShell - Deploying a solution

In SharePoint 2010,you have two Command Line tool in SharePoint 2010,

1.Windows PowerShell.
2.SharePoint 2010 Management Shell.

In Windows PowerShell, you need to add SharePoint snapin to use all the Sharepoint objects,
           Add-PSSnapin "Microsoft.SharePoint.PowerShell"
an to remove snapin
           Remove-PSSnapin "Microsoft.SharePoint.PowerShell"

But in SharePoint 2010 Management Shell,you can straight away use all the above command because it has a built in SharePoint snapin.

Below are the commands used to Deploy solution file(.WSP) to sharepoint,

A] Add Solution

stsadm 
a.  stsadm -o addsolution -filename “SolutionFile”
Ex:
stsadm -o addsolution -filename "C:\testsln.wsp”
Powershell
a.      Add-SPSolution -LiteralPath “SolutionFile”
Ex:
Add-SPSolution -LiteralPath "C:\testsln.wsp"

B] Delete Solution
stsadm
a.   Stsadm -o deletesolution -name “SolutionName”
Ex:
Stsadm -o deletesolution -name “testsln.wsp”
Powershell
a.       Remove-SPSolution -Identity “SolutionName”
Ex:
Remove-SPSolution -Identity “testsln.wsp”

C] Deploy Solution
stsadm
To All Web Applications
a.      stsadm -o deploysolution -name “SolutionName” -immediate -allowgacdeployment –allcontenturls
Ex: 
stsadm -o deploysolution -name “testsln.wsp” -immediate -allowgacdeployment –allcontenturls

To Particular Web Application
i.      stsadm -o deploysolution -name “SolutionName”-immediate -allowgacdeployment -url  “SiteURL”
Ex: 
stsadm -o deploysolution -name “testsln.wsp”-immediate -allowgacdeployment -url  “http://Site:1000”

PowerShell
To All Web Application
i.      Install-SPSolution “SolutionName” -AllWebApplication  –GACDeployment
Ex: 
Install-SPSolution “testsln.wsp” -AllWebApplication  –GACDeployment

To Particular Web Application
i.    Install-SPSolution “SolutionName” -WebApplication   “SiteURL” -GACDeployment
Ex: 
Install-SPSolution “testsln.wsp” -WebApplication “http://Site:1000″ -GACDeployment

D] Retract Solution
stsadm
To All WebApplication
i.      stsadm -o retractsolution -name “SolutionName” -immediate –allcontenturls
To Particular WebApplication
i.      stsadm -o retractsolution -name “testsln.wsp”-immediate -url “http://Site:1000″

PowerShell
To All WebApplication
i.      Uninstall-SPSolution “SolutionName” -AllWebApplication ”
To Particular WebApplication
i.      Uninstall-SPSolution “testsln.wsp” -WebApplication  “http://Site:1000"

E] Enable Feature
Stsadm
To All WebApplication
—– Not Available—-
To Particular WebApplication
i.      stsadm -o activatefeature -name “FeatureName” -url  “SiteURL”
Ex: stsadm -o activatefeature -name “testsln_Feature1″ -url  “http://Site:1800″

PowerShell
To All WebApplication
i.      Get-SPWebApplication | ForEach-Object {Enable-SPFeature
“FeatureName” -Url $_.Url -confirm:$false}
Ex: Get-SPWebApplication | ForEach-Object {Enable-SPFeature “testsln_Feature1″ -Url $_.Url -confirm:$false}

To Particular WebApplication
i.      Enable-SPFeature -Identity “FeatureName” -Url “SiteURL”
Ex: Enable-SPFeature -Identity “testsln_Feature1″ -Url “http://Site:1000″

F] Disable Feature
stsadm
To All WebApplication
—– Not Available—-
To Particular WebApplication
i.      stsadm -o deactivatefeature -name “FeatureName” -url   “SiteURL”
Ex:
stsadm -o deactivatefeature -name “listitemlimitsolution_Feature1″ -url “http://Site:1800”
PowerShell
To All WebApplication
i.      Get-SPWebApplication | ForEach-Object {Disable-SPFeature
“FeatureName” -Url $_.Url -confirm:$false}
Ex:
Get-SPWebApplication | ForEach-Object {Disable-SPFeature
“listitemlimitsolution_Feature1″ -Url $_.Url -confirm:$false}
To Particular WebApplication
i. Enable-SPFeature -Identity “FeatureName″ -Url “SiteURL″

Diasble-SPFeature -Identity “testsln_Feature1″ -Url “http://Site:1000″

No comments:

Post a Comment