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?