Get all content databases and set the warning & maximum number of sites

Hello SharePoint PowerShell experts.  I need help with a script, and I will admit, I'm really NOT good at arrays.

We have multiple (25 content DBs to be exact) for one web app that have the out of the box 2000/5000 for warning and maximum # of sites.  I can get all the content DBs and I tried to SET them but it only sets one Content DB.  Here's what I mean:

This script gets me ALL of the content DBs:


Get-SPContentDatabase | %{Write-Output "$($_.Name)”;} 


I also tried this:

 $db = Get-SPContentDatabase | %{Write-Output "- $($_.Name)”; foreach($site in $_.sites){write-Output $site.url}}

$db.MaximumSiteCount = 200

$db.WarningSiteCount = 100

$db.Update()

 

That just updated the very first content db but not all of them.  Can someone help?

Parents
No Data
Reply
  • Got it!  Thank you for your help!!!

    $webapp = "http://yoursite.com"
    $maxsite = "200"
    $warnsite = "100"

     

    #Add the SharePoint PowerShell Snap-In
    add-pssnapin microsoft.sharepoint.powershell -EA 0

    ForEach($db in (Get-SPContentDatabase -webapplication $webapp)){

        Set-SPContentDatabase -Identity $db -MaxSiteCount $maxsite -WarningSiteCount $warnsite

Children
No Data