As a SharePoint developer or Admin, what we do
most frequently in our day-to-day activities; is to play around with SharePoint
solutions (WSPs) and Features..
And since we cannot memorize all the available
operations, here are simplified PowerShell commands:
SPSolution Operations:
Add Solution to SharePoint Farm-
You are ready with solution package (WSP) for deployment and this is a fresh
deployment; first time deployment to the farm. SharePoint can consume a
solution only if it is uploaded in SP solution store, and the operation to
upload a solution is Add-SPSolution
Command:
Add-SPSolution
-LiteralPath -Confirm
Parameters:
LiteralPath: Mandatory, Takes full path of
WSP as string
Confirm: Optional, Ask for confirmation
before operation
Example:
Add-Spsolution
-Literalpath "C:\Solutions\MySolution.wsp"
Install Solution - Now solution
is available in farm, next step is to use it. Installing a WSP comes with many
options based on scope (for specific web application or all) and content
(DLL(s) for GAC or files).
Command:
Install-SPSolution
-Identity -GACDeployment
Install-SPSolution
-Identity -AllWebApplication -GACDeployment
Install-SPSolution
-Identity -WebApplication -GACDeployment
Parameters:
Identity: Required, Full name/GUID of WSP as
string
AllWebapplications: Optional, If WSP to be
used by all webapplications in farm
WebApplication: Optional, If WSP is for
specific web application, URL as string
GACDeployment: Optional, If WSP includes some
DLL to GAC
Force: this parameter can be used if
installation is throwing some error due to feature activation or time job
issue.
Confirm: Optional, Ask for confirmation
before operation
Example:
Install-SPSolution
-Identity "MySolution.wsp" -GACDeployment
Install-SPSolution
-Identity "MySolution.wsp" -AllWebApplication -GACDeployment
Install-SPSolution
-Identity "MySolution.wsp" -WebApplication "http://mysite.mydomain.com/" -GACDeployment
Upgrade a deployed Solution-
Your solution package (WSP) is already deployed and installed; now you did some
changes in code and want to deploy the latest, here comes Update-SPSolution.
This command will upgrade the deployed solution with latest DLL(s) and files.
Command:
Update-SPSolution
-Identity -LiteralPath
-GACDeployment
Parameters:
Identity: Required, Full name/GUID of WSP as
string
LiteralPath: Mandatory, Takes full path of
WSP as string
GACDeployment: Optional, If WSP includes some
DLL to GAC
Force: this parameter can be used if
installation is throwing some error due to feature activation or time job
issue.
Confirm: Optional, Ask for confirmation
before operation
Example:
Update-SPSolution
-Identity MySolution.wsp -LiteralPath "C:\Solutions\MySolution.wsp"
-GACDeployment
Deployment Rollback: There are
scenarios where we may need to rollback the deployment; If the deployment
caused some major issue in farm/application or you added a big component
(i.e.-site/list definition) in you solution and want a fresh deployment. To
rollback a deployment, first retract/uninstall the WSP and then remove it from
farm.
Retract Solution - Similar to
installation, uninstalling a WSP comes with many options based on scope (for
specific web application or all).
Command:
Uninstall-SPSolution
-Identity -Confirm
Uninstall-SPSolution
-Identity -AllWebApplication -Confirm
Uninstall-SPSolution
-Identity -WebApplication -Confirm
Parameters:
Identity: Required, Full name/GUID of WSP as
string
AllWebapplications: Required, If WSP to be
retracted from all webapplications in farm
WebApplication: Required, If WSP is for
specific web application, URL as string
Confirm: Optional, Ask for confirmation
before operation
Example:
Uninstall-SPSolution
-Identity "MySolution.wsp"
Uninstall-SPSolution
-Identity "MySolution.wsp" -AllWebApplication -Confirm:$false
Uninstall-SPSolution
-Identity "MySolution.wsp" -Webapplication "http://mysite.mydomain.com/" -Confirm:$false
Remove Solution to SharePoint Farm-
After retraction, solution can be removed from SharePoint farm solution store.
Command:
Remove-SPSolution
-Identity -Confirm
Parameters:
Identity: Required, Full name/GUID of WSP as
string
Confirm: Optional, Ask for confirmation
before operation
Example:
Remove-SPSolution
"MySolution.wsp"
Remove-SPSolution
-Identity "Unilever.Global.CDF.wsp" -Confirm:$false
SPFeature Operations:
Install/Uninstall Features in SharePoint
Farm- Normally feature installation/un-installation are taken care
with SPSolution operations which contains the feature. But we come across
situations where features needs to be Installed/Uninstalled separately. Below
are the commands and examples.
Install Feature Command:
Install-SPFeature -Path
-Force -Confirm
Parameters:
Path: Mandatory, Takes relative path from the
folder “$env:ProgramFiles\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\FEATURES\” to the feature as string
Confirm: Optional, Ask for confirmation
before operation ($true/$false)
Force: Optional, this parameter can be used for
force installation.
Example:
Install-SPFeature -Path "MyFeature"
Un-Install Feature Command:
Uninstall-SPFeature
-Path -Force -Confirm
Parameters:
Path: Mandatory, Takes relative path from the
folder “$env:ProgramFiles\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\FEATURES\” to the feature as string
Confirm: Optional, Ask for confirmation
before operation ($true/$false)
Force: Optional, this parameter can be used
for force operation.
Example:
Uninstall-SPFeature -Path "MyFeature"
Activate/Deactivate Feature-
Below are the commands and examples.
Activate Feature Command:
Enable-SPFeature
–Identity -URL Force
-Confirm
Parameters:
Identity: Required, Name or GUID of feature
as string
URL: Optional,Site/Web URL depending on
feature scope
Confirm: Optional, Ask for confirmation
before operation ($true/$false)
Force: Optional, this parameter can be used
for force installation.
Example:
Enable-SPFeature –Identity "MyFeature" -URL "http://mysite.mydomain.com"
Deactivate Feature Command:
Disable-SPFeature
–Identity -URL Force
-Confirm
Parameters:
Identity: Required, Name or GUID of feature
as string
URL: Optional,Site/Web URL depending on
feature scope
Confirm: Optional, Ask for confirmation
before operation ($true/$false)
Force: Optional, this parameter can be used
for force operation.
Example:
Disable-SPFeature –Identity "MyFeature" -URL "http://mysite.mydomain.com"
No comments:
Post a Comment