When were my site collections created?

Have you ever wondered when your site collections were created?
Try the following one liner to get all the information you need:

Get-SPSite -Limit All | %{$root = $_.rootweb; $date = $root.created.toShortDateString(); Write-Host "$($root.url) was created on $($date)"}

image

Advertisements

Change site collection administrators for all site collections

In a minute, I will show you how to change the site collection administrators for all site collections using PowerShell. Thanks to Maarten Peeters for helping!

But first, it may be easy to get a result for all the current site collection administators, in case you want to roll back:

Get-SPSite -Limit all | FT Url, Owner, SecondaryContact -AutoWidth

image

Now if you want to change all site collection administrators and secondary site collection administrators (As you would set in Central Administration)

Get-SPSite -Limit All | %{Set-SPSite $_ -OwnerAlias "<domain\user>" -SecondaryOwnerAlias "<domain\user>"}

If you are using MySites and personal sites have been created, you might want to use the following, to exclude the MySite site collections. Please check if you are using the "personal" managed path. If you are using a different managed path, you can change the "*/personal/*" to reflect your environment.

Get-SPSite -Limit All | ?{$_.url -notlike "*/personal/*"} | %{Set-SPSite $_ -OwnerAlias "<domain\user>" -SecondaryOwnerAlias "<domain\user>"}

I hope this helps someone out there to save some valuable time!