Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
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
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
PowerShell : Delete All Site Collection Present Under Web Application
WhatsApp
Ketak Bhalsing
May 20
2016
1.6
k
0
0
#check to see if the PowerShell Snapin is added
if
( (Get-PSSnapin -Name
"Microsoft.SharePoint.PowerShell"
-ErrorAction SilentlyContinue) -eq $
null
)
{
Add-PsSnapin
"Microsoft.SharePoint.PowerShell"
}
Start-SPAssignment -Global
function DeleteAllSiteCollections([
string
]$url)
{
try
{
$webApp = Get-SPWebApplication $url
foreach
($siteCol
in
$webApp.Sites)
{
Remove-SPSite –Identity $siteCol.Url –GradualDelete –Confirm:$False
Write-Host
"Successfully removed the site: "
$siteCol.Url -ForegroundColor Green
}
}
catch
[System.Exception]{ Write-Host $_.Exception.ToString()}
}
$webAppUrl = Read-Host
"Enter the url of the Web Application"
DeleteAllSiteCollections $webAppUrl
Stop-SPAssignment -Global
PowerShell
SharePoint
Site Collection
Up Next
PowerShell : Delete All Site Collection Present Under Web Application