Wednesday 9 July 2014

Install WSP Using PowerShell

Deploying WSP
=====================
Open PowerShell and Run as Administrator
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
Batch File Name.: DeployWSP.bat
---------------------------------------------------------------
@Set SiteURL="http://SP2010:1234/mysite"
Echo "Deploying My WSP"
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe Set-ExecutionPolicy RemoteSigned; .\WSPFOlder\DeployWSP.ps1 -SiteURL %SiteURL%
PowerShell Script Name:DeployWSP.ps1
--------------------------------------------------------------------------
Param
(
[string]$SiteURL = $null
)
write-host "Adding Snapin"
Add-PsSnapin Microsoft.SharePoint.PowerShell
write-host "Added"
$site=new-object Microsoft.SharePoint.SPSite($SiteURL);
$web=$site.RootWeb;
write-host "Installing WSP"
Add-SPSolution .\WSPFOlde\MyFeature.wsp
Start-Sleep -s 100
Install-SPSolution -Identity MyFeature.wsp -GACDeployment -force
Start-Sleep -s 100
write-host "Installtion of WSP Done."
write-host "Removing Snapin"
Remove-PsSnapin Microsoft.SharePoint.PowerShell
write-host "Removed"
=======================================================================================================================================================================
Undeploying WSP
=====================
Batch File Name:UndeployWSP.bat
-----------------------------------------------------------------------
@Set SiteURL="http://SP2010:1234/mysite"
Echo "Undeploying My WSP"
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe Set-ExecutionPolicy RemoteSigned; .\WSPFOlder\UndeployingWSP.ps1 -SiteURL %SiteURL%
PowerShell Script Name:UndeployingWSP.ps1
------------------------------------------------------------------------------------
Param
(
[string]$SiteURL=$null
)
write-host "Adding Snapin"
Add-PsSnapin Microsoft.SharePoint.PowerShell
write-host "Added"
write-host "Undeploying My WSP."
Uninstall-SPSolution -identity MyFeature.wsp -Confirm:$false
Start-Sleep -s 100
Remove-SPSolution -identity MyFeature.wsp -Confirm:$false
Start-Sleep -s 100
write-host "My WSP Uninstalled."
write-host "Removing Snapin"
Remove-PsSnapin Microsoft.SharePoint.PowerShell
write-host "Removed"
======================================================================================================================================================================
Sharepoint 2010 wsp installation and uninstallation
Install wsp
Add New Wsp
-----------------
Add-SPSolution “D:\MySPSolution.wsp“
Install-SPSolution –Identity MySPSolution.wsp –WebApplication http://sp2010 –GACDeployment
Update wsp
-------------
Update-SPSolution –Identity MySPSolution.wsp –LiteralPath “D:\MySPSolution.wsp” –GacDeployment
unInstall wsp
Uninstall-SPSolution –Identity MySPSolution.wsp –WebApplication http://sp2010
Remove-SPSolution–Identity MySPSolution.wsp
========================================================================
WSP Depoyment Using STSADM Commands
------------------------------------------------------------
Open Command Prampt
Go to this path: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
Install:
stsadm -o addsolution -filename c:\Mysolution.wsp
stsadm -o deploysolution -name Mysolution.wsp -local -allowGacDeployment -force -url http://Server:3333/
Uninstall:
stsadm -o retractsolution -name Mysolution.wsp -immediate -allcontenturls
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name Mysolution.wsp -override
stsadm -o execadmsvcjobs