People picker settings for all Web Applications one-liner

Summary: This PowerShell one-liner will show the people picker settings for each Web Application, including Central Administration.

If you want to know the settings for the people picker in your SharePoint farm, you can run the following line of PowerShell.
It will retrieve all Web Applications and show the people picker settings for each one.

Get-SPWebApplication -IncludeCentralAdministration | %{Write-Host $_.url; $_.peoplepickersettings | select * | fl }

Running the one-liner will result in something like this:

People picker settings

Site collection creation time using PowerShell

This script will show you the site collection creation time for each site collection using PowerShell.
Try the following oneliner 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)"}

Site collection creation time

Change site collection administrators using PowerShell

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 -AutoSize

Site collection administrators

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 "<domainuser>" -SecondaryOwnerAlias "<domainuser>"}

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 "<domainuser>" -SecondaryOwnerAlias "<domainuser>"}

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

Content Databases per Web Application oneliner

Another one in the series of oneliners. This one will show you all Web Applications, and all associated Content Databases for these Web Applications:

Get-SPWebApplication | %{Write-Output "`n- $($_.url)"; foreach($cd in $_.contentdatabases){Write-Output $cd.name}}

The output will look similar to this:Get Content Databases per Web Application onelinerYou can output this to a text file by running the following:

Get-SPWebApplication | %{Write-Output "`n- $($_.url)"; foreach($cd in $_.contentdatabases){Write-Output $cd.name}} >> <strong>D:filename.txt</strong>

Current cache accounts PowerShell oneliner

This oneliner will show you the currently configured cache accounts for each of your Web Applications. Just paste this line of code in your SharePoint Management Shell:

Get-SPWebApplication | %{Write-Host "Web Application: " $_.url "`nSuper user: " $_.properties["portalsuperuseraccount"] "`nSuper reader: " $_.properties["portalsuperreaderaccount"] "`n"}

This is the output for the above command in my test environment:

Current cache accounts PowerShell oneliner

In my case, I have not properly configured the super user accounts for all my Web Applications.

Be aware that misconfigured super user accounts can lead to access problems. You may not be able to access your SharePoint Web Application!

Get Site Collections per Content Database oneliner

This will be a very short post, as it contains only 1 line of PowerShell code, and is not very hard to understand. It shows you all content databases, and for each of the content databases, it will show you the site collections within this content database.

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

That wasn’t so bad right? Just copy and paste this code into your SharePoint Management Shell (As administrator), and let PowerShell do your work for you!

Get Site Collections per Content Database oneliner

Now let’s say you want to save this output to a .txt file, you can add

> C:sitecollections.txt

The full command would be:

Get-SPContentDatabase | %{Write-Output "- $($_.Name)”; foreach($site in $_.sites){write-Output $site.url}} > C:sitecollections.txt

This would create a .txt file with the same information:

Get Site Collections per Content Database oneliner 2

That’s all there is to it!