Most
commonly used entities in SharePoint are Subsite, site collection, list and
libraries.
GUI mode will be the easiest mode to do any functional activities associated with them. In this article, i am more concentrating on the PowerShell mode because its very easy and efficient way to clean the activity directly from the database.
GUI mode will be the easiest mode to do any functional activities associated with them. In this article, i am more concentrating on the PowerShell mode because its very easy and efficient way to clean the activity directly from the database.
Let's try to
explore some deletion functionalities by means of PowerShell.
How
to delete a site collection by using PowerShell?
Remove-SPSite
[-Identity] <SPSitePipeBind> [-AssignmentCollection
<SPAssignmentCollection>] [-Confirm [<SwitchParameter>]]
[-DeleteADAccounts <SwitchParameter>] [-GradualDelete
<SwitchParameter>] [-WhatIf [<SwitchParameter>]]
Example:
Remove-SPSite -Identity http://SharePoint2010/sites/test2010
Where:
SharePoint2010:
web application URL.
Sites:
wildcard entry.
test2010:
site collection that you want to delete.
Note: The
above will completely deletes an existing site collection and all subsites.
This operation cannot be undone.
How
to delete a Subsite by using PowerShell?
Remove-SPWeb
[-Identity] <SPWebPipeBind> [-AssignmentCollection
<SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Recycle
<SwitchParameter>] [-WhatIf [<SwitchParameter>]]
Example:
Remove-SPWeb -Identity http://SharePoint2010/sites/test2010/subtest2010
Where:
SharePoint2010:
web application URL.
Sites:
wildcard entry.
test2010:
site collection
subtest2010:
Subsite that you want to delete.
If you want
to delete multiple subsites in a single
shot from a site collection then please refer the following site: http://get-spscripts.com/2010/10/delete-sharepoint-sub-sites-using.html
How
to delete a Document Library by using PowerShell?
Please
refer the following code by which you can delete a document library without any
issues...
$web =
Get-SPWeb urlofweb
$library
= $web.lists["listname"]
$library.Delete()
How
to delete a SharePoint List by using PowerShell?
Get-SPWeb
“site collection link” | % {$_.Lists.Delete([System.Guid]$_.Lists["name of
list"].ID)}
The above
command will delete the mentioned list without any issues...
If you
have any queries/questions regarding the above mentioned information then
please let me know, Thank you. I would be more than happy to help you as well
as resolves your issues...
Hi Amol ,
ReplyDeleteGreat blog ,looking really professional,Thanks for sharing this post .
Sharepoint Developers
Thanks Harry.
DeleteReally wanted to appreciate your efforts Amol, you are really doing a very good job by posting such valuable information...
ReplyDeleteLet me confirm you that i used this article information for my requirements and completed my work without any issues.... even more i got the appreciation from my manager but i know that credit goes to you only :) :) Thank you Amol!