Find and remove All Faulty Features in SharePoint 2013 Farm


If you have upgraded content dabases from different farms and have databases with missing featuers you can use FeatureAdmin. I have enhanced it a little bit :)

https://gallery.technet.microsoft.com/office/Feature-Optimized-b379e038

Click LIst All Faulty Features – Can take tike if farm is large.

Export the list for record

Either select one by one of click Delete all.

You should run this a few times to make sure your farm is clean.

FEatureAdminExtension-Latest

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()

Usage Service Application Proxy Stopped on Central Admin


In case the proxy of usage service application is showed as stopped, the following PowerShell code can get it back to normal.

$Usage = Get-SPServiceApplicationProxy | where {$_.TypeName –eq “Usage and Health Data Collection Proxy”}
$Usage.Provision()

In my case it took couple of minutes to get back so be patient.  Basic but useful.

Azure Resource Manager and New Portal


This post is part of a series.

Part 1 : Azure Basics

Part 2: New Portal & Azure RM Basics

Part 3:Creating a Basic Template in Visual Studio

Part 4:Preparing Template for SharePoint Farm Deployment with DSC

OK. Now we have said HelloWorld to Azure let’s discuss about ARM or Azure Resource Manager. If you have played with the classic portal you would have noticed that User interface design is kind of “Singular”. Various services or features are accessible at their own link. The only way to kind of way to group things in that UI is the name your components in a certain way. Take a look at the screenshot.

clip_image002

You could see right in the middle that I have used a certain naming convention to identify various elements of my application. LUC-ObjectName-UniqueID is my unique way. I have a Cloud service, a Virtual Network, messed up storage account name and a Domain Controller VM. Cloud service does provide some kind of logical structure but it is not that consistent and you have to browse and click many times to find out what is what if you need to find out.

clip_image004

You can see above that my cloud service has a VM inside and then you click on top of the VM link to find more information. This is what the new portal or Azure Resource Manager has fixed. Just imagine your data center where servers are sitting in a room, everything is accessible at one place. Server, network devices, load balancers etc. This is exactly what ARM provides you, an ability to group you infrastructure at one single place but this is not all.

I will go back to PowerShell from here. May be PowerShell for Azure Deserve one post but here is what you need to learn. PowerShell is not the only way to access Azure Resources. Microsoft has provided many different option which allows you to provision and manage resources in Azure. PowerShell is of course for people that use Windows, CLI (Command-Line Interface) for MAC and Linux users and a REST API which can be used by any platform.

To read about CLI click here

To ready about how to use PowerShell click here

So what is the issue with classic portal and PowerShell? With classic PowerShell you can automate you deployments by write hundreds of lines of PowerShell scripts but these script must be executed sequentially. You would need to change these script for every deployment. Running things sequentially takes time and as your deployment becomes complex it becomes harder to maintain it.

Let’s get back to Azure Resource Manager, It provides the ability to follow a complete development lifecycle of developing, testing and deploying your resources in Azure. JSON based templates allow you to write your deployment declaratively and test them before you go to production. RBAC or Role based access control allows you to apply access rules to users based on their role and expertise. I am a SharePoint person so I should not see the NIC or Load Balancers on the new portal. A small but PowerShell feature of “Tags” is provided to tag resources with (string,string) or key value pairs which can later be used to group resources. Just Managed Metadata in SharePoint.

Make sure you put the word “Deployment” in your mind when you think about ARM. Anything you want to do in new portal will be a new deployment, either creator a VM or adding a network card.

Resource Groups

Resource Groups are places where you will see all the resources that you have deployed. Resources have one to one relationship with Resource Group. RBAC can be applied on Resource Groups. There are other features as well but they are not important right now.

Resource Providers & Resources

Resource providers are like buckets or sections where you can pick and buy stuff, just like shopping malls. As per my understanding there are number of resource providers, Compute, Networking, Data & Storage, Web & Mobile etc. You can find all the information from here. Each provider provide a specialty items e.g. the network provides NIC, NLB, Public IP and Virtual Network Resources. Compute provides Virtual Machines, Remote App etc. Each individual item that you can add to your deployment is called a Resource.

Deployment Template

If you are a developer then it would be easy for you. Deployment Template is set of JSON files that defines what you are doing to deploy in Azure. All the properties are written as JSON Schema which you just need to provide string based key value pair. Look at the example below (Not a useable one).

{
	"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"storageAccountType": {
		"type": "string",
		],
		"metadata": {
		"description": "Storage Account type"
		}
},
	"dnsLabelPrefix": {
	"type": "string",
	"metadata": {
		"description": "DNS Label for the Public IP. Must be lowercase. It should match with the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$ or it will raise an error."
		}
	}
},
"variables": {
	"location": "[resourceGroup().location]",
},
	"resources": [
	{
		"type": "Microsoft.Storage/storageAccounts",
		"name": "[variables('storageAccountName')]",
	}
},

{

"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "[variables('apiVersion')]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsLabelPrefix')]"
}
}
}
]
}

I think that is more than enough for you to start. I will not write more about it. Microsoft azure web site contains detailed description for each element. You can access it all from

Azure Resource Manager Overview and related Info

https://azure.microsoft.com/en-us/documentation/articles/resource-group-overview/

Azure Resource Manager Architecture

https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-azure-resource-manager-architecture/

New Portal or “The” Portal

You can access the portal at https://portal.azure.com. It is much fancier than the classic one and build based on Blades concept. Anything you click will open in a blade and flip right. You can maximize it whenever needed and it refreshes automatically most of the times.

clip_image006

You will still some similarities like left navigation and classic options like class portal but the core function are accessible either from Resource Groups or when you click on New. Below is a view of what it looks when you browse a Resource Group. Now all that I wrote above would make sense.

clip_image008

Now let’s create a VM exactly what we did in classic portal. The first thing you will notice that you just need to Click + New => Compute and then all VM templates will be visible to you.

clip_image010

You can click on See all if you want to see the large number of images that you can use to build your VM.

clip_image012

I just clicked on Windows Server 2016 Evaluation by searching

clip_image014

clip_image016

Now all I have to do choose how I want to create the VM in classic mode or RM mode. I will choose Resource Manager.

On Section one I typed a unique VM name, username and password and then a Resource Group name. I can also select existing and click OK. I will be sent to next tab.

clip_image018

Then I need to choose the Size. Click View All if you want to choose one of your choice. There are lot of VMS. Click on the Size and Click Select.

clip_image020

Then you would see that all required resources will appear automatically. These resources will be

Storage Account, Network, Monitoring and Availability Group. You would be amazed that most of fill up automatically. You can change then the way you want. You can see that I am adding an availability group where I am setting the update domains to 2 and Fault domain to max. You can choose based on what is available in your region.

clip_image022

Last screen is just a summary of what you need.

Simply Click OK and your process will start.

clip_image024

A new blade will appear on the home page and there is bell on the top which will show you notification when things are going well.

clip_image026

If you click on the blade you will see the status of deployment. Top section will show you all the parameters that you have selected and bottom will show you deployment of each resource.

clip_image028

Give it few minutes and then refresh the portal.

The deployment is complete, let take a look at Resource Group

clip_image030

Just under the VM name there is a connect button. Click on it enter credential and you are in.

clip_image032

clip_image034

So we have created our first VM using new Portal and Azure Resource Manager Template.

clip_image036

This is end of Part 2. In the next part we will look at how we can develop a Custom ARM template using Visual Studio 2015.