How to the fix the iCloud Backup (Never) problem in iPhone?

I am not one of the biggest Apple fan boy, but speaking truth I have been using their iPhone (thus iOS) for more than 5 years now. My first iPhone was iPhone 4.

Having said that, I am usually one of the consumers who would upgrade their devices on the very first day of it’s release of the newest iOS. To be honest, I have also been brave enough to run my iPhone with one of their BETA builds of iOS 5. Wasn’t a bad experience I should say.

Coming back to the iOS9, I was once again done with my first day upgrade and no issue noticed for the first 2 weeks untill one fine day my iPhone says that I haven’t backedup my iPhone for 2 weeks.

Strange. I use iCloud backup and it is supposed to auto-back up whenever I am Wi-Fi and charging.

I tried to manually press the “Back up Now” button but it would just not do anything. Another weird thing was that it also indicated my iPhone has NEVER been backed up but within “Manage Storage”, indicated that only 3 GB was left. I was like where is the other 2 GB gone.

Anyway, after numerous tries and going through suggestion on various forums I called up the Apple Support Customer number. Must say, I liked the call back option. The first executive was not very supportive and friendly. Was not able to help me and just ended up giving me the case ID and asked to call later.

Tried again after a week. This time, the fellow tried his best and even went to discuss the case with a “Senior Expert” (not sure what that means). Eventually, asked me to use the iTunes backup and sold the idea of purchasing more iCloud space. Good salesman skills :).

However, I was like I am not using much data to be backed up and quite sure that it’s way less than the free 5 GB.

Getting help from no official Apple support, I tried the following and am so glad that it worked like charm.

  1. Create a backup of iPhone manually on your computer using iTunes. See instructions here at: https://support.apple.com/en-us/HT203977
  2. Reset your iPhone to factory settings. https://support.apple.com/en-us/HT201274
  3. Setup you iPhone as a new Phone and DO NOT USE the backup option.
  4. AGAIN, Reset your iPhone to factory settings (Step 2).
  5. This time, use the backup from computer instead. See here: https://support.apple.com/en-us/HT204184

If everything goes well, you should have the backup working with iCloud.

How to quickly setup your Azure Development Environment?

More than a post, this is note to self.

Honestly, over the years it has been so easier to set-up the development environment time and again. I use Azure Virtual Machines as my personal development environment. And of course, this being a personal development environment is ought to be not as clean as you would like it to be and there are chances that you want to recreate it from scratch. Here are the steps which I use to re-create by development environment:

Create Azure Virtual Machine

Of course, you can create a new machine via the portal. I just prefer to create it via the following script:

Change basic settings and Windows Features

Such as:

  • Install IIS
  • Disable Loopbackcheck
  • Enable PS Remoting
  • Disable IE Security Check
  • Set Execution Policy for PowerShell
  • Install Chocolatey (used later for installation of packages)

Chocolatey comes to picture

Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind. Lately, I am a lot dependent on this and why not, I don’t have to keep a links of software, packages which I want to install. Chocolatey makes sure every-time I install the packages, I have the latest version and that too with just a single command. Isn’t it cool!

The essentials which I always install are as:

  • Visual Studio
  • Fiddler
  • Chrome
  • Firefox
  • NotePad++
  • WinMerge
  • Visual Studio Code

Passing –Yes to the choco command makes sure that it runs in the silent mode.

Of course, this is not the actual configuration of my development environment but this is how I usually start and my environment evolves based on need. Also, I deliberately skipped installation of SQL Server from this post and in scripts as it gives me a reason to make use of Azure SQL Servers.

Task services has failed with an unknown exception

While installing SharePoint 2010 on a clean Windows 2008 R2 box, I received the following error:

Task services has failed with an unknown exception
Exception: System.InvalidOperationException: The specified value for the LocStringId parameter is outside the bounds of this enum.


Exception: System.InvalidOperationException: The specified value for the LocStringId parameter is outside the bounds of this enum.
	at Microsoft.SharePoint.Portal.WebControls.StringResourceManager.ConvertLocStringIdToStringFast(LocStringId lsid)
	at Microsoft.SharePoint.Portal.WebControls.StringResourceManager.GetString(LocStringId lsid)
	at Microsoft.Office.Server.ApplicationRegistry.SharedService.ApplicationRegistryServiceInstance.get_TypeName()
	at Microsoft.SharePoint.PostSetupConfiguration.ServicesTask.InstallServiceInstanceInConfigDB(Boolean provisionTheServiceInstanceToo, String serviceInstanceRegistryKeyName, Object sharepointServiceObject)
	at Microsoft.SharePoint.PostSetupConfiguration.ServicesTask.InstallServiceInstances(Boolean provisionTheServiceInstancesToo, String serviceRegistryKeyName, Object sharepointServiceObject)
	at Microsoft.SharePoint.PostSetupConfiguration.ServicesTask.InstallServices(Boolean provisionTheServicesToo)
	at Microsoft.SharePoint.PostSetupConfiguration.ServicesTask.Run()
	at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()

Even after trying multiple Windows restart, SharePoint 2010 Repair procedures nothing really helped. What eventually helped was an un-expected trick posted on one of the MSDN Forums here.

So, what you need to do is REMOVE the registry key at the following location and the re-run the configuration wizard.


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\Services\_Microsoft.Office.Server.ApplicationRegistry.SharedService.ApplicationRegistryService] 

And also,


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\ServiceProxies\Microsoft.Office.Server.ApplicationRegistry.SharedService.ApplicationRegistryServiceProxy]

Happy SharePoint 🙂

How to Set Check-in Policies for all Projects in Team Foundation Server using PowerShell?

The Team Foundation Server 2013 provides the administrators with opportunity to add check-in policies to the Source Control Settings.  These check-in policies define that while checking in the code in the Team Foundation Server Version Control (either TFS Version Control or GIT), the user has to perform certain extra actions. These actions vary from adding comments to describe the check-in, linking the check-in to one or more work items defined the in the product backlog or to make sure that your build successfully passes all the unit tests defined in the project.

The check-in policies are defined on the Team Project level. However when you have a Team Project Collection with hundreds of various team projects, you want a way with which you can standardize the check-in policies for all the team projects.

Unfortunately,  Team Foundation Server does not support this functionality out of the box. But luckily, you can use the Team Foundation Server SDK to implement this programmatically. The PowerShell script below shows how to set Check-in Policies for all Team Projects in Team Foundation Server using PowerShell.

The script makes use of the SetCheckinPolicies on the Team Project object. What it does is basically retrieving all the available projects in the Team Project Collection and looping through all available projects to set the check-in policy individually.

You would notice that the script makes use of two policies:

  • Work Item
  • Check for Comments

However, you can extend this or change to select other installed policies on your workstation. You would notice that script makes use of InstalledPoliciyTypes on the work station. It basically makes use of the registered policy assemblies from the registry under the path:

 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\TeamFoundation\SourceControl\Checkin Policies

TFS Policy


[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Common")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Controls")


function AddPolicyOnProject($project){
	$policies = @()
	
	$policies += AddToPolicyEnvelope($workItemPolicy)
	$policies += AddToPolicyEnvelope($checkForComments)
	
	$project.SetCheckinPolicies($policies)
	
	Write-Host "Adding Policies to" $project.Name
}

function AddToPolicyEnvelope($policy){
	$policyType = $installedPolicyTypes | where {$_.Name -eq $policy.Type}
	return New-Object -TypeName Microsoft.TeamFoundation.VersionControl.Client.PolicyEnvelope -ArgumentList @($policy, $policyType)
}

$serverName = "http://manasbhardwaj.net/tfs/Projects"

$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)
$versionControlType = [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]
$versionControlServer = $tfs.GetService($versionControlType)
$projects = $versionControlServer.GetAllTeamProjects($true)

$installedPolicyTypes = [Microsoft.TeamFoundation.VersionControl.Client.Workstation]::Current.InstalledPolicyTypes

$workItemPolicy = New-Object -TypeName Microsoft.TeamFoundation.VersionControl.Controls.WorkItemPolicy
$checkForComments = New-Object -TypeName CheckForCommentsPolicy.CheckForComments

$projects | foreach { AddPolicyOnProject $_ }


A PowerShell alternative to SharePoint 2013 AppRegNew.aspx

If you are reading this post then chances are that you are already aware of the SharePoint 2013 App Model and especially the SharePoint 2013 Provider Hosted Apps.

A provider-hosted app for SharePoint consists of both an app for SharePoint that is deployed directly to a SharePoint 2013 site and a separately deployed web application. If the provider-hosted web application is an ASP.NET web application, you can use the Office Developer Tools for Visual Studio 2013 to create both components of a provider-hosted app for SharePoint.

Packaging and publishing a SharePoint 2013 provider-hosted app can be a lengthy process. MSDN has a detailed article here explaining the process and steps required to publish a SharePoint provider-hosted App.

The standard process of registering an app on a SharePoint 2013 environment is by using the appregnew.aspx page (http://sitecollection/_layouts/15/appregnew.aspx) and generating a Client Id which can be used to communicate between the SharePoint and the provider-hosted app to establish a high-trust.

appregnew.aspx

However, this approach of generating Client Id can be cumbersome when you have different environments (DTAP street)  with-in your organization. I did not want to burden my application administrators by creating complexity of the installation process  to generate the Client Id per environment and change it in several places (the .app package, web.config etc.)

Not only this, it also adds a lot of confusion when multiple developers are working together and all of them have to generate their own Client Ids for respective machines. The checked-in web.config, app packages in source controller can really create unnecessary confusion.

A similar blog about this process is posted here.

However, PowerShell can come to your rescue to generate the Client Id once and use the same Client Id to register your SharePoint App in different environment. Yes, not only in DTAP street but also various developer machine working together on a product.

The small PowerShell snippet below can automate the whole process of registering an App with a given Client Id and after that installing it in SharePoint.

For those who are interested in details, it makes use of Register-SPAppPrincipal command. This command lets an on-premise or SharePoint Online administrator register an app principal which means you can also use it for Office 365.


$clientID = "74599670-eb74-4348-9e7a-f9dc07c576a2"
$appFile = "C:\Temp\MyApp.app"
$siteCollection = "http://manasbhardwaj.net"
$appName = "My App"
 
$web = Get-SPWeb -Identity $siteCollection
 
$realm = Get-SPAuthenticationRealm -ServiceContext $web.Site;
$appIdentifier = $clientID  + '@' + $realm;
 
#Register the App with given ClientId
Register-SPAppPrincipal -DisplayName $appName -NameIdentifier $appIdentifier -Site $web | Out-Null
 
$app = Import-SPAppPackage -Path $appFile -Site $siteCollection -Source ObjectModel -Confirm:$false 	
 
#Install the App
Install-SPApp -Web $siteCollection -Identity $app	| Out-Null

Download Script