Rename Central Admin Database


If you had ran Configuration Wizard to create your SharePoint Farm then your Admin Content database will have AdminContent_XXX-XXXX-XXXXX (Guid) in its name.  If you want to fix it, so you SQL Management studio looks good and no one actually blames you to be a bad SharePoint Admin, you can use the script below.

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
#List all web applications
Get-SPWebApplication -IncludeCentralAdministration

$CentralAdminUrl = "http://sp2013:2013/"
$CentralAdminDB = Get-SPContentDatabase -WebApplication $CentralAdminUrl
#Verify the database object is good
$CentralAdminDB.Name

#New DB Name
$NewCentralAdminDBName = "01_Content_NewCentralAdmin"
$NewCentralAdminContentDB = New-SPContentDatabase -Name $NewCentralAdminDBName -WebApplication $CentralAdminUrl -MaxSiteCount 2 -WarningSiteCount 1
#Verify the database is added
Get-SPContentDatabase -WebApplication $CentralAdminUrl
#Verify the database object is good 
$NewCentralAdminContentDB
#Move the Sites to nicely named DB
$CentralAdminDB.Sites | % {Move-SPSite $_ -DestinationDatabase $NewCentralAdminContentDB -Confirm:$false -Verbose}
iisreset
#Verify the Site collection are moved
Get-SPContentDatabase -WebApplication $CentralAdminUrl
#If databases are moved then dismount the orignal DB

Dismount-SPContentDatabase $CentralAdminDB -Confirm:$false -Verbose
#Confirm First Database is gone
Get-SPContentDatabase -WebApplication $CentralAdminUrl
#Delete the database from SQL Server 

Update User Profile Feed Identifer after User Profile Re-Creation


The script can be used to re-create the user profile feed identifier property.  If this property is not set the user will not be able to use Social features like newsfeed on my site host.

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
$MySiteHost = new-object Microsoft.SharePoint.SPSite("https://mysites.contoso.com/");  
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($MySiteHost);  

$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext);  
$profile = $ProfileManager.GetUserProfile("contoso\adamb"); 
$Site = $profile.PersonalSite
$Site | Select *
$Site.RootWeb.Created
#If Personal Site needs to be created.  The feed Identifier will be added automatically in that case.
#$profile.CreatePersonalSite()
$profile.FeedIdentifier
#If My Site Already Exist.
$microFeedId = ($Site.Url + ";1." + $Site.ID.ToString().Replace("-", "") + "." + $Site.RootWeb.ID.ToString().Replace("-", "") + "." + $Site.RootWeb.Lists["Microfeed"].ID.ToString().Replace("-", "") + ".0c37852b34d0418e91c62ac25af4be5b")
$profile["SPS-FeedIdentifier"].Value = $microFeedId
$profile.Commit()
$Site.Dispose()
$MySiteHost.Dispose()

Powershell Script to Find Owners of Document Library SharePoint


Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue

$SiteUrl = "https://portal.contoso.com"
$SiteCollection = Get-SPSite $SiteUrl
foreach($web in $SiteCollection.AllWebs)
{
    foreach($list in $web.Lists)
    {
        if($list.BaseType -eq "DocumentLibrary" -and $list.Hidden -eq $false)
        {
            if($list.Permissions.Inherited -eq $false)
            {
                foreach($Perm in $list.Permissions)
                {
                    if($Perm.PermissionMask -eq "FullMask")
                    {
                        Write-Host $web.Url, $list.Title $Perm.Member -ForegroundColor Green
                    }
                }
            }
        }
    }
    $web.Dispose()
}
$SiteCollection.Dispose()