Change site collection administrators using powershell

To change primary or secondary site collection administrator (viewable in CA - Application Management - Site Collections -
- Change site collection administrators
Set-SPSite -Identity "<SiteCollection>" -SecondaryOwnerAlias "<User>"
or
Set-SPSiteAdministration %sitename% -OwnerAlias domain\user -SecondaryOwnerAlias domain\user

Note - it cannot add more than primary or secondary administrator.
Update: script to add user as administrator

The SiteAdministrators collection of the SPWeb object returns a SPUserCollection of all the Site Collection Administrators for the site in question.

Unfortunately, it doesn’t appear to actually allow you to “ADD” new users to the Site Collection Administrators via this collection like you can do with any other SPUserCollection for a user.

Whether it’s a bug, or not, a simple way around this is to do the following:


$web = Get-SPWeb %sitename%

$web.AllUsers.Add(“domain\user”,[System.String]::Empty,”Domain Users”,[System.String]::Empty)

$spUser = $web.AllUsers[“domain\user”]

$spUser.IsSiteAdmin = $true

$spUser.Update()

Change site collection administrators using powershell

SharePoint: PowerShell Script to List All Users in All Groups

Here’s a quick little PowerShell script to list all groups and all users. Note that if an AD group is listed as a user, all the users in that group may not show up in this list until the user has visited SharePoint at least once.

For both SharePoint 2007 or 2010 in any PowerShell:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$site = New-Object Microsoft.SharePoint.SPSite("http://yourservername/sites/yoursitecollection ")

$groups = $site.RootWeb.sitegroups

foreach ($grp in $groups) {"Group: " + $grp.name; foreach ($user in $grp.users) {"  User: " + $user.name} }

$site.Dispose()

 

or for SharePoint 2010 in the SharePoint 2010 Management Shell:

$site = Get-SPSite http://yourservername/sites/yoursitecollection 

$groups = $site.RootWeb.sitegroups

foreach ($grp in $groups) {"Group: " + $grp.name; foreach ($user in $grp.users) {"  User: " + $user.name} }

$site.Dispose()


Also take a look:
http://geekswithblogs.net/bjackett/archive/2009/04/24/the-power-of-powershell-and-sharepoint-enumerating-sharepoint-permissions-and.aspx
SharePoint: PowerShell Script to List All Users in All Groups

create virtual smtp server to test outgoing email

setup smtp server:

http://support.microsoft.com/kb/303707/en-us

how to test smtp server:

http://support.microsoft.com/kb/323350

configure email in IIS:

http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/configure-smtp-e-mail-in-iis-7-and-above

codeplex smtp server:

http://www.therobman.com/blog/index.php/2010/07/31/test-smtp-server-for-sharepoint-outgoing-email-settings/

 

create virtual smtp server to test outgoing email