PowerShell Code Snippets for SharePoint2010 Developers
- by ybbest
Install solution to SharePoint Farm and activate Feature to a site collection
#Please specify the solution package path.
$SolutionPackagePath = “C:\ybbest\myForm.xsn”
Add-SPSolution -LiteralPath $SolutionPackagePath
#Please specify the site collection url.
$SiteCollectionUrl=”http:// ybbest /”
# Install the solution package to the SharePoint Farm
Install-SPSolution -Identity ybbest.wsp -GACDeployment
#Activate features in the solution package to a Site Collection
Enable-SPFeature -Identity 8ed800a2-3494-4cba-adf1-ed8714cb062d -Url $SiteCollectionUrl
Retract solution from SharePoint Farm and deactivate Feature to a site collection
#Deactivate features from a Site Collection
Disable-SPFeature -Identity 8ed800a2-3494-4cba-adf1-ed8714cb062d -Url http:// ybbest /
# Uninstall the solution package to the SharePoint Farm
Uninstall-SPSolution -Identity ybbest.wsp
# Remove the solution package to the SharePoint Farm
Remove-SPSolution -Identity ybbest.wsp
Install Admin Approved InfoPath form
#Please specify the template path.
$InfopathFormTemplatePath = “C:\ybbest\myForm.xsn”
#Please specify the site collection url.
$SiteCollectionUrl=”http:// ybbest /”
#Install InfoPath to the SharePoint Farm
$formTemplate=Install-SPInfoPathFormTemplate -Path $InfopathFormTemplatePath
#Activate InfoPath form to Site Collection
Enable-SPInfoPathFormTemplate -Identity $formTemplate -Site $SiteCollectionUrl
References
http://technet.microsoft.com/en-us/library/ee806878.aspx
http://www.wssdemo.com/Lists/PowerShell/Commands.aspx