Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Useful PowerShell Command for SharePoint Administrator
WhatsApp
Amir Reza
8y
17.2
k
0
0
25
Blog
Add PowerShell to ISE.
Command:
Add-PSSnapin Microsoft.SharePoint.PowerShell
Find an error from Correlation ID.
Command:
get-splogevent | ?{$_.Correlation -eq "
<Correlation ID>
"} | select Category, Level, EventID,Message | Format-List > C:\Correlationerror.log
This Command list error message with Category, Level, EventID, Message in “C” drive by correlationerror name in notepad.
Creating Site collection.
Command:
New-SPSite -Url "Your site url" -Name "MyTesting Site" -Template "STS#0" -OwnerAlias "Domain\owner" -Language 1033
This example creates an English site collection owned by owner with Team Site Template. Lots of parameter can add as per requirement.
Restore a deleted site collection.
Command:
Get-SPDeletedSite
This command lists all deleted site with WebApplicationId, DatabaseID, SiteSubscriptionID, SiteID, Path, Scheme, Url, DeletionTime parameter.
Restore-SPDeletedSite –Identity SiteID
Find Respective SiteID of deleted site collection from Get-SPDeletedSite and replace it to Restore-SPDeletedSite –Identity SiteID.
Export SharePoint List and library.
Command:
export-spweb -identity http://mytestsite -path c:\listName.cmp -itemurl /Lists/EmployeeDetails –includeusersecurity
http://mytestsite ->
site collection name.
EmployeeDetails
-> List name.
c:\listName.cmp
-> Save In C drive by listName with .cmp Extention.
Import SharePoint List
Command:
Import-SPWeb -identity "http:// mytestsite " -path c:\listName.cmp –force
"http:// mytestsite "
is Site collection name where have to import.
c:\listName.cmp
is path from where we have to import listName.
Backup SharePoint Site Collection.
Command:
Backup-SPSite –Identity http://MySiteCollection/ -Path C:\Backup\MysiteCollection.bak -Verbose
Note:
Verbose use to see progress.
Restore SharePoint Site Collection.
Command:
Restore-SPSite –Identity http://MySiteCollection/ -Path C:\Backup\MysiteCollection.bak -Force -Verbose
Backup SharePoint Farm
Command:
Backup-SPFarm -BackupMethod Full –Directory C:\FarmBackup\SPFarm
Note:
Above command Backups the entire database.
Or
Command:
Backup-SPFarm -BackupMethod Differential –Directory C:\FarmBackup\SPFarm
Note:
Backs up only the changes made to the database since the last full backup. The differential backup method cannot be used to back up Index databases or Document Libraries. The Full backup method must be used to back up these resources.
Restore SharePoint Farm
Command:
Restore-SPFarm -Directory C:\FarmBackup -RestoreMethod overwrite
Add Solution -> Adds a SharePoint solution package to the farm.
Command:
Add-SPSolution C:\customsolution.wsp
C is directory and customsolution.wsp is solution name.
Install SharePoint Solution -> Deploy the SharePoint Solution in the Farm.
Command:
Install-SPSolution –Identity customsolution.wsp –WebApplication http://webapplicationsite–GACDeployment
Note:
If you are using the GAC or Code Access Security, Specify either –GACDeployment or –CASPolicies.
–WebApplication parameter applies for particular web application.
If have to apply for all web application use –AllWebApplications (Hope manifest allow this) Or don’t add –WebApplication parameter. You can also use –Force parameter to force the deployment.
Uninstall SharePoint solution
Command:
Uninstall-SPSolution –Identity customsolution.wsp –WebApplication http://webapplicationsite
Update SharePoint Solution
Command:
Update-SPSolution –Identity customsolution.wsp –LiteralPath C:\customsolution.wsp –GACDeployment
Remove SharePoint Solution.
Command:
Remove-SPSolution –Identity customsolution.wsp
Uploads a new sandboxed solution package to the solution gallery.
Command:
Add-SPUserSolution –LiteralPath c:\customsandboxsolution.wsp –Sitehttp://mysitecollection
Deploy Sandboxed solution.
Command:
Install-SPUserSolution –Identity customsandboxsolution.wsp –Site http://mysitecollection
Upgrade existing Sandboxed solution.
Command:
Update-SPUserSolution –Identity customsandboxsolution.wsp –Site http://mysitecollectionToSolution customsandboxsolution2.wsp
Uninstall Sandboxed Solution.
Command:
Uninstall-SPUserSolution –Identity customsandboxsolution.wsp –Sitehttp://mysitecollection
Remove Sandboxed solution package from the solution gallery.
Command:
Remove-SPUserSolution –Identity customsandboxsolution.wsp –Site http://mysitecollection
Enable SharePoint Features
Command:
Enable-SPFeature –Identity FeatureNameOrGUID –Url http://your site name
Disable SharePoint Features
Command:
Disable-SPFeature –Identity FeatureNameOrGUID –Url http://your site name
Usefull PowerShell Command
SharePoint
Administrator
Up Next
How To Get All Site Collection Administrators From SharePoint Online Site Collections Using PnP PowerShell
Ebook Download
View all
Getting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JS
Read by 4.9k people
Download Now!
Learn
View all
Membership not found