SharePoint: Add/Remove Site Collection administrators with Powershell

Following examples shows how to work with site collection administrators with PowerShell:

Scenario: Remove secondary site collection administrator altogether from the site collection without replacing it with any other user.

Solution: The SecondaryContact property of SPSite object needs to be set to null in order to remove the Secondary Site collection administrator.
$siteCollectionUrl = "http://sp2010:90"
$site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
$site.SecondaryContact = $null
Scenario: Set  primary and secondary site collection administrator of a site collection. 
This can be done in following two ways:
$siteCollectionUrl = "http://sp2010:90"
$site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
$web = $site.RootWeb
$primarAdministrator = $web.EnsureUser("sp2010\administrator")
$site.Owner = $primarAdministrator;
$secondayAdministrator = $web.EnsureUser("sp2010\Nadeem.Yousuf")
$site.SecondaryContact = $secondayAdministrator;
Set-SpSite "http://sp2010:90" -owneralias "sp2010\Nadeem.Yousuf"
Set-SpSite "http://sp2010:90" -SecondaryOwnerAlias "sp2010\administrator"
Scenario: Show primary and secondary site collection administrator of a site collection.

Get-SPSite "http://sp2010:90" | Select Owner
Get-SPSite "http://sp2010:90" | Select SecondaryContact

profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts