To access power shell go to Start -> All Programs -> Microsoft SharePoint 2010 Products
and the click on SharePoint 2010 Management Shell. You should have proper permission to use execute powershell cmdlets or commands.
Here I am providing some examples:
Get-SPFarm:
When you type this and press enter, it will give you the farm name and status wether it is online or offline.
Get-spwebapplication:
It will give you the displayname of list of web applications and there URL.
Get-spwebapplication -includecentraladministration:
This will give display name of list of web applications as well as the name of the central administartion and there corresponding URL.
Get-SPSite:
Returns all site collections.
Get-SPSite http://site-name/
This will give you all the sites from the given URL.
Add-SPSolution:
Add-SPSolution -LiteralPath [Path of WSP file]:
This will adds a SharePoint solution package to the farm.
Install-SPSolution:
Install-SPSolution -Identity [WSP file name] -GACDeployment:
This will deploys an installed SharePoint solution in the farm.
Add-SPUserSolution:
Add-SPUserSolution -LiteralPath [WSP file path] -Site http://yoursitename
The Add-SPUserSolution cmdlet uploads a new sandboxed solution package to the solution gallery.
Install-SPUserSolution:
Install-SPUserSolution -Identity [wspfilename] -Site http://yoursitename
The Install-SPUserSolution cmdlet activates a sandboxed solution in a site collection.
Install-SPFeature:
This cmdlet will Installs a SharePoint Feature by using the Feature.xml file.
Install-SPFeature -path "MyTestFeature"
Install-SPWebPartPack:
This will Install the specified Web Part package to the specified location
Install-SPWebPartPack "MyCustomWebPartPack" -LiteralPath "path of wpp" -GlobalInstall
GlobalInstall means it will install in GAC.
Install-SPWebTemplate:
This will install a site template.
Install-SPWebTemplate –path "template file path" –name "My Custom Template" –description "Test site template"
Get-SPServer:
It will return the list of servers.
Get-SPServer
Get-SPLogEvent:
Returns results from a Unified Logging Service (ULS) trace log
Get-SPLogEvent -MinimumLevel "Warning"
Get-SPDatabase:
It will give us all the properties of database.
Get-SPDatabase –ServerInstance "Bijay\SharePoint"
Backup-SPSite:
Perform a back up of a site collection.
and the click on SharePoint 2010 Management Shell. You should have proper permission to use execute powershell cmdlets or commands.
Here I am providing some examples:
Get-SPFarm:
When you type this and press enter, it will give you the farm name and status wether it is online or offline.
Get-spwebapplication:
It will give you the displayname of list of web applications and there URL.
Get-spwebapplication -includecentraladministration:
This will give display name of list of web applications as well as the name of the central administartion and there corresponding URL.
Get-SPSite:
Returns all site collections.
Get-SPSite http://site-name/
This will give you all the sites from the given URL.
Add-SPSolution:
Add-SPSolution -LiteralPath [Path of WSP file]:
This will adds a SharePoint solution package to the farm.
Install-SPSolution:
Install-SPSolution -Identity [WSP file name] -GACDeployment:
This will deploys an installed SharePoint solution in the farm.
Add-SPUserSolution:
Add-SPUserSolution -LiteralPath [WSP file path] -Site http://yoursitename
The Add-SPUserSolution cmdlet uploads a new sandboxed solution package to the solution gallery.
Install-SPUserSolution:
Install-SPUserSolution -Identity [wspfilename] -Site http://yoursitename
The Install-SPUserSolution cmdlet activates a sandboxed solution in a site collection.
Install-SPFeature:
This cmdlet will Installs a SharePoint Feature by using the Feature.xml file.
Install-SPFeature -path "MyTestFeature"
Install-SPWebPartPack:
This will Install the specified Web Part package to the specified location
Install-SPWebPartPack "MyCustomWebPartPack" -LiteralPath "path of wpp" -GlobalInstall
GlobalInstall means it will install in GAC.
Install-SPWebTemplate:
This will install a site template.
Install-SPWebTemplate –path "template file path" –name "My Custom Template" –description "Test site template"
Get-SPServer:
It will return the list of servers.
Get-SPServer
Get-SPLogEvent:
Returns results from a Unified Logging Service (ULS) trace log
Get-SPLogEvent -MinimumLevel "Warning"
Get-SPDatabase:
It will give us all the properties of database.
Get-SPDatabase –ServerInstance "Bijay\SharePoint"
Backup-SPSite:
Perform a back up of a site collection.
Backup-SPSite [Site URL] -Path C:\Backup\siteback.bak
1.Backup and Restore in SharePoint 2010 using PowerShell
how to take an Backup/Restore of SharePoint Site Collection
Go to Start->All Program-> Microsoft SharePoint 2010 Products->open SharePoint 2010 Management Shell
Backup a Site collection with PowerShell command:
Backup-SPSite -Identity http://myserver -Path "c:\backup\file.bak"
Restore a Site Collection with PowerShell command:
To restore site collection you’ll use the following command. Use –Force if you want to overwrite the existing site collection
Restore-SPSite -Identity http://myserver -Path "c:\backup\file.bak"
2.Deploy SharePoint 2010 solution(.wsp) package using Powershell
Follow below steps:
Step1: Start Power Shell command prompt
Start->All Programs->MicrosoftSharepoint2010Products->open Sharepoint2010Managementshell
Type the command
Step2: Add Solution Package
Add-SPSolution “C:\SharePoint2010Solution.wsp”
Step3: Install Solution Package
Install-SPSolution –Identity SharePoint2010Solution.wsp –WebApplication http://myserver –GACDeployment
If you are using Sandbox Solution,
Step4: Install Solution Package
Install-SPUserSolution –Identity SharePoint2010Solution.wsp –WebApplication http://myserver –GACDeployment
For Updating the Sharepoint 2010 Solution type the following commands
Step5: Update Solution Package
Update-SPSolution –Identity SharePoint2010Solution.wsp –LiteralPath “C:\SharePoint2010Solution.wsp” –GacDeployment
For retract and remove a solution, type the following commands:
Step 6: Uninstall Solution Package
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://myserver
Step7: Remove Solution Package
Remove-SPSolution–Identity MySharePointSolution.wsp
Production :
These steps are required: (in PowerShell)
ADA
A - Add - Add-SPSolution
D - Deploy - Install-SPSolution - GACDeployment - AllWebApplications
A - Activate - /_layouts/newdwp.aspx
Then, to update: Update-SPSolution -GACDeployment
3.Powershell command to install activate feature SharePoint 2010
Powershell commands to:
- Install Feature:
Install-SPFeature FeatureFolderName
Here FeatureFolderName folder must be presented inside C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES directory.
- Activate/Enable Feature:
Enable-SPFeature FeatureFolderName -Url http://ur-site-url
- Disable Feature:
Disable-SPFeature FeatureFolderName -Url http://ur-site-url
Here FeatureFolderName folder must be presented inside C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES directory.
- Uninstall Feature:
Uninstall-SPFeature FeatureFolderName
Here FeatureFolderName folder must be presented inside C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES directory.
4.Get System Accounts using PowerShell
Description:
SPProcessAccount helps us to get all the system accounts like LocalSystem account, LocalService account and NetworkService account.
Get-SPProcessAccount:
This command will retrieve all the above accounts.
But if you want to retrieve indivisually then we have to follow below commands:
LocalSystem account:
Get-SPProcessAccount –LocalSystem
LocalService account:
Get-SPProcessAccount -LocalService
NetworkService account:
Get-SPProcessAccount –NetworkService
5.PowerShell commands for SharePoint database
Commands to see all databases:
Get-SPDatabase
The above command will return all databases.
If you want to retrieve a particular databse then follow below command:
Get-SPDatabase-Identity <GUID>
Cmdlet to get all the web applications:
Get-SPWebApplication
Command to create new content database:
New-SPContentDatabase –Name ContentDBName –WebApplication "Web Application URL"
Cmdlet to retrieve all content database for a particular web application:
Get-SPContentDatabase –WebApplication "Web Application URL"
Get-SPContentDatabase –WebApplication "http://bsahoo3:2600/"
Cmdlets to Attach a Content Database to a Web Application:
Mount-SPContentDatabase –Name "ContentDBName" –WebApplication "Web Application URL"
Cmdlet to Delete a Content Database:
Remove-SPContentDatabase "ContentDBName"
Cmdlet to Create a New Configuration Database:
New-SPConfigurationDatabase –DatabaseName NewConfigurationDBName –DatabaseServer "Database Server name"
Cmdlet to Delete a Configuration Database:
Remove-SPConfigurationDatabase
This command will delete the current configuration database.
Cmdlet to take backup of a configuration database:
Backup-SPConfigurationDatabase –Directory C:\DatabaseBackUp
Cmdlet to take restore of a configuration database:
Restore-SPFarm –Directory C:\DatabaseBackUp
Cmdlet to Back Up the SharePoint Farm:
Backup-SPFarm –BackupMethod Full –Directory C:\FarmBackup
Full means it will take backup of the entire farm.
Cmdlet to Restore the SharePoint Farm:
Restore-SPFarm –Directory C:\FarmBackup –RestoreMethod Overwrite
Cmdlet to Back Up a Site Collection:
Backup-SPSite –Identity "http://Site Collection URL"–Path C:\SiteCollectionBackup\MySiteCollection.bak
Cmdlet to Restore a Site Collection
Restore-SPSite –Identity "http://Site Collection URL"–Path C:\SiteCollectionBackup\MySiteCollection.bak –Force
How To configure FBA in sharepoint 2013 and 2010 Step by step
ReplyDelete