Thursday 12 June 2014

SharePoint WSP Deployment Using Power Shell Commands

Get-Help New-SPWebApplication -Example
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
-----------------------------------------------------
TO Remove
-------
Remove-PSSnalin Microsoft.Sharepoint.PowerShell
----------------------------------------------------------------------------------
Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” | format-table name > C:\SP2010PowershellCommands.txt
Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” > C:\SP2010PowershellCommands2.txt
Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” | format-table Definition > C:\SP2010PowershellCommands3.txt
--------------------------------------------------------------------------------------------
New-SPWebApplication -ApplicationPool "SharePoint - 80" -Name "SP1234"
------------------------------------------------------------------------------
Deploy.bat
------------------
@Set SiteURL="http://SERVER:8888"
Echo "Deploying My WSP"
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe Set-ExecutionPolicy RemoteSigned; "C:\Users\v-nanara\Desktop\T\9thDec\CustomWebpartTest\BatchFile\DeployWSP.ps1" -
SiteURL %SiteURL%
=================
UnInstall.bat
-----------------
@Set SiteURL="http://SERVER:8888"
Echo "Undeploying My WSP"
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe Set-ExecutionPolicy RemoteSigned; "C:\Users\v-nanara\Desktop\T\9thDec\CustomWebpartTest\BatchFile\UndeployingWSP.ps1"
-SiteURL %SiteURL%
==============================================================
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 "C:\Users\v-nanara\Desktop\T\9thDec\CustomWebpartTest\CustomWebPartTest\CustomWebPartTest\bin\Debug\CustomWebPartTest.wsp"
Start-Sleep -s 100
Install-SPSolution -Identity CustomWebPartTest.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”
=======================================================================
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 CustomWebPartTest.wsp -Confirm:$false
Start-Sleep -s 100
Remove-SPSolution -identity CustomWebPartTest.wsp -Confirm:$false
Start-Sleep -s 100
write-host “My WSP Uninstalled.”
write-host “Removing Snapin”
Remove-PsSnapin Microsoft.SharePoint.PowerShell
write-host “Removed”
====================================================================================================
1.Develop Custom Webpart
Open PowerShell and Run as Administrator
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
Adding
------------
write-host “Adding Snapin”
Add-PsSnapin Microsoft.SharePoint.PowerShell
write-host “Added"
Add-SPSolution “D:\MySPSolution.wsp“
Install-SPSolution –Identity MySPSolution.wsp –WebApplication http://SP2010:8888 –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
Or below
Uninstall-SPSolution -identity MySPSolution.wsp -Confirm:$false
Remove-SPSolution -identity MySPSolution.wsp -Confirm:$false
===========================================================================================================
Specific to One site
=========================================================================================================
--------------
write-host “Adding Snapin”
Add-PsSnapin Microsoft.SharePoint.PowerShell
write-host “Added"
Adding
-----
Add-SPSolution “C:\CustomWebPartTest.wsp"
Install-SPSolution –Identity CustomWebPartTest.wsp –WebApplication http://SP2010:8888 –GACDeployment
Update wsp
————-
Update-SPSolution –Identity MySPSolution.wsp –LiteralPath “D:\MySPSolution.wsp” –GacDeployment
Uninstall
--------------
Uninstall-SPSolution –Identity CustomWebPartTest.wsp –WebApplication http://SP2010:8888 -Confirm:$false
Remove-SPSolution -identity CustomWebPartTest.wsp -Confirm:$false
write-host “Removing Snapin”
Remove-PsSnapin Microsoft.SharePoint.PowerShell
write-host “Removed