Remove a link for the specified account name using SharePoint 2010 web service in powershell

Steps Involved:
  1. Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
  2. Run the following script.

Powershell Script:

 
##Remove a link for the specified account name using SharePoint 2010 web service in powershell
$uri="http://serverName:10736/sites/ECT2/_vti_bin/UserProfileService.asmx?wsdl"
## $accountName is a string that contains the account name for which you need to remove a link
[
String]$accountName="domainName\userName"
## $accountName is a int that contains the unique ID for the link to remove
[
Int]$id=7

## Web Service Reference - http://Site/_vti_bin/UserProfileService.asmx
$userProfileWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential

## To get the user link id please refer the commented script
# $QuickLinkData=$userProfileWebServiceReference.GetUserLinks($accountName)
# foreach($link in $QuickLinkData)
# {
# Write-host -ForegroundColor Green $link.Name
# Write-host -ForegroundColor Green $link.Id
# }

## Remove the link
$userProfileWebServiceReference.RemoveLink($accountName,$id)