Wednesday, June 25, 2014

SharePoint Search - Restrict result source to a single content type

Ever tried adding a result source in SharePoint to restrict your results to a single content type?
The query builder makes it sound easy by giving you options to add a simple filter ContentType "equals" "your content type".

Resutls? NONE returned.

Finally figured out that manually giving the contentype ID as "Contains starts with" > Manual value does the trick!


Friday, June 20, 2014

SharePoint 2013 workflow : The server was unable to process the request


Here, I received another SharePoint 2013 workflow error.
This time the workflow was not able to send emails and the following error was being shown

Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP Unauthorized to http://sitename/_vti_bin/client.svc/web/lists/getbyid(guid'guid') Correlation Id: id Instance Id: id

Fortunately I came across this post which gave me the answer
http://sharepoint.stackexchange.com/questions/89101/failed-to-retrieve-the-com-class-factory-for-component-with-clsid-sp-sprequest

Solution 1:
In InetMgr, go to advanced settings for Security Token Service Application Pool and change "Load User Profile" to true. Recycle application pool.

Reason 2 and Solution 2 : There could be another reason for this error. The workflow authentication can fail if the user executing the workflow (this will be the user initiating the workflow) is given permission through active directory group and the container for this group is not selected to be synchronised in the active directory connection.

You can test this out by giving the user permissions directly on the site through a SharePoint group and re-trying the workflow again.


Significant ULS Log Entries are given below :
SPApplicationAuthenticationModule: Failed to build cache key for user
The set of claims could not be mapped to a single user identity. Exception Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA). has occured.
The registered mappered failed to resolve to one identity claim. Exception: System.Runtime.InteropServices.COMException (0x800703FA): Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA). at Microsoft.SharePoint.Library.SPRequest..ctor() at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, SPAppPrincipalToken appPrincipalToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) at Microsoft.SharePoint.SPRequestManager.GetContextRequest(SPRequestAuthenticationMode authenticationMode) at Microsoft.SharePoint.Administration.SPFarm.get_RequestAny() at Microsoft.SharePoint.SPSecurity.GetCurrentUserTokenNoApplicationPrincipalDelegated() at Microsoft.SharePoint.SPSecurity.GetCurrentUserToken() at Microsoft.SharePoint.SPSecurity.EnsureOriginatingUserToken() at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Microsoft.Office.Server.Security.UserProfileIdentityClaimMapper.GetMappedIdentityClaim(Uri context, IEnumerable`1 identityClaims) at Microsoft.SharePoint.IdentityModel.SPIdentityClaimMapperOperations.GetClaimFromExternalMapper(Uri contextUri, List`1 claims)
STS Call Claims Saml: Problem getting output claims identity. Exception: 'System.Runtime.InteropServices.COMException (0x800703FA): Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA). at Microsoft.SharePoint.Library.SPRequest..ctor() at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, SPAppPrincipalToken appPrincipalToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) at Microsoft.SharePoint.SPRequestManager.GetContextRequest(SPRequestAuthenticationMode authenticationMode) at Microsoft.SharePoint.Administration.SPFarm.get_RequestAny() at Microsoft.SharePoint.SPSecurity.GetCurrentUserTokenNoApplicationPrincipalDelegated() at Microsoft.SharePoint.SPSecurity.GetCurrentUserToken() at Microsoft.SharePoint.SPSecurity.EnsureOriginatingUserToken() at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Microsoft.Office.Server.Security.UserProfileIdentityClaimMapper.GetMappedIdentityClaim(Uri context, IEnumerable`1 identityClaims) at Microsoft.SharePoint.IdentityModel.SPIdentityClaimMapperOperations.GetClaimFromExternalMapper(Uri contextUri, List`1 claims) at Microsoft.SharePoint.IdentityModel.SPIdentityClaimMapperOperations.ResolveUserIdentityClaim(Uri contextUri, ClaimCollection inputClaims) at Microsoft.SharePoint.IdentityModel.SPIdentityClaimMapperOperations.GetIdentityClaim(Uri contextUri, ClaimCollection inputClaims, SPCallingIdentityType callerType) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.GetLogonIdentityClaim(SPRequestInfo requestInfo, IClaimsIdentity inputIdentity, IClaimsIdentity outputIdentity, SPCallingIdentityType callerType) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.EnsureSharePointClaims(SPRequestInfo requestInfo, IClaimsIdentity outputIdentity, SPCallingIdentityType callerType) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.AugmentOutputIdentityForRequest(SPRequestInfo requestInfo, IClaimsIdentity outputIdentity) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.GetOutputClaimsIdentity(IClaimsPrincipal principal, RequestSecurityToken request, Scope scope)'.
STS Call: Failed to issue new security token. Exception: System.Runtime.InteropServices.COMException (0x800703FA): Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA). at Microsoft.SharePoint.Library.SPRequest..ctor() at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, SPAppPrincipalToken appPrincipalToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) at Microsoft.SharePoint.SPRequestManager.GetContextRequest(SPRequestAuthenticationMode authenticationMode) at Microsoft.SharePoint.Administration.SPFarm.get_RequestAny() at Microsoft.SharePoint.SPSecurity.GetCurrentUserTokenNoApplicationPrincipalDelegated() at Microsoft.SharePoint.SPSecurity.GetCurrentUserToken() at Microsoft.SharePoint.SPSecurity.EnsureOriginatingUserToken() at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Microsoft.Office.Server.Security.UserProfileIdentityClaimMapper.GetMappedIdentityClaim(Uri context, IEnumerable`1 identityClaims) at Microsoft.SharePoint.IdentityModel.SPIdentityClaimMapperOperations.GetClaimFromExternalMapper(Uri contextUri, List`1 claims) at Microsoft.SharePoint.IdentityModel.SPIdentityClaimMapperOperations.ResolveUserIdentityClaim(Uri contextUri, ClaimCollection inputClaims) at Microsoft.SharePoint.IdentityModel.SPIdentityClaimMapperOperations.GetIdentityClaim(Uri contextUri, ClaimCollection inputClaims, SPCallingIdentityType callerType) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.GetLogonIdentityClaim(SPRequestInfo requestInfo, IClaimsIdentity inputIdentity, IClaimsIdentity outputIdentity, SPCallingIdentityType callerType) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.EnsureSharePointClaims(SPRequestInfo requestInfo, IClaimsIdentity outputIdentity, SPCallingIdentityType callerType) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.AugmentOutputIdentityForRequest(SPRequestInfo requestInfo, IClaimsIdentity outputIdentity) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.GetOutputClaimsIdentity(IClaimsPrincipal principal, RequestSecurityToken request, Scope scope) at Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.Issue(IClaimsPrincipal principal, RequestSecurityToken request) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.Issue(IClaimsPrincipal principal, RequestSecurityToken request)
SPSecurityContext: Request for security token failed with exception: System.ServiceModel.FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.ReadResponse(Message response) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst) at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context, Boolean bearerToken, SecurityToken onBehalfOf, SecurityToken actAs, SecurityToken delegateTo, SPRequestSecurityTokenProperties properties)
An exception occurred when trying to issue security token: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs..
SPApplicationAuthenticationModule: Error authenticating request, Error details { Header: {0}, Body: {1} }. Available parameters: 3001000;reason="There has been an error authenticating the request.";category="invalid_client" {"error_description":"The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs."} .
Application error when access /_vti_bin/client.svc, Error=The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.ReadResponse(Message response) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst) at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context, Boolean bearerToken, SecurityToken onBehalfOf, SecurityToken actAs, SecurityToken delegateTo, SPRequestSecurityTokenProperties properties) at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForApplicationAuthentication(Uri context, SecurityToken onBehalfOf) at Microsoft.SharePoint.IdentityModel.SPApplicationAuthenticationModule.<>c__DisplayClass4.b__3() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.IdentityModel.SPApplicationAuthenticationModule.ConstructIClaimsPrincipalAndSetThreadIdentity(HttpApplication httpApplication, HttpContext httpContext, SPFederationAuthenticationModule fam) at Microsoft.SharePoint.IdentityModel.SPApplicationAuthenticationModule.AuthenticateRequest(Object sender, EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


Workflow suspended error for Reason 2

RequestorId: guid. Details: RequestorId: guid. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ApplicationException: HTTP 401 {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}} {"Transfer-Encoding":["chunked"],"X-SharePointHealthScore":["0"],"SPClientServiceRequestDuration":["6"],"SPRequestGuid":["dguid"],"request-id":["ddd1f137-185d-9315-8eb4-456650fc11be"],"X-FRAME-OPTIONS":["SAMEORIGIN"],"Cache-Control":["max-age=0, private"],"WWW-Authenticate":["Negotiate","NTLM"],"X-AspNet-Version":["4.0.30319"],"X-Powered-By":["ASP.NET"],"X-Content-Type-Options":["nosniff"],"X-MS-InvokeApp":["1; RequireReadOnly"],"MicrosoftSharePointTeamServices":["15.0.0.4535"],"Date":["Thu, 10 Sep 2015 00:56:01 GMT"]} at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


ULS Logs for Reason 2

Category Message
Application Authentication SPApplicationAuthenticationModule: Failed to build cache key for user
Claims Authentication SPJsonWebSecurityBaseTokenHandler: ValidateActorIsSelfIssuer! Issuer '00000005-0000-0000-c000-000000000000' is not self issuer.
User Profiles Couldn't find a user using property 'WorkEmail' of value xxxx@xxxx.xx
Claims Authentication STS Call Claims Saml: Successfully requested oauth claim identity.
Authentication Authorization OAuth app principal Name=i:0i.t|ms.sp.ext|guid@guid, IsAppOnlyRequest=False, UserIdentityName=0#.w|domain\user, ClaimsCount=16
CSOM Request does not have SPBasePermissions.UseRemoteAPIs permission. Need to check it when each API is accessed
CSOM The request does not have required permission to access SP.RequestContext.Current
CSOM Exception occured in scope Microsoft.SharePoint.SPContext.get_current. Exception=System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.     at Microsoft.SharePoint.Client.ServerStub.CheckRequiredResourceRight(ProxyContext proxyContext, String memberName, ResourceRight right)     at Microsoft.SharePoint.Client.ServerStub.CheckBlockedGetProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.ServerStub.SPContextServerStub.GetStaticProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ServerStub.GetStaticPropertyWithMonitoredScope(String propertyName, ProxyContext proxyContext)
CSOM Original error: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.     at Microsoft.SharePoint.Client.ServerStub.CheckRequiredResourceRight(ProxyContext proxyContext, String memberName, ResourceRight right)     at Microsoft.SharePoint.Client.ServerStub.CheckBlockedGetProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.ServerStub.SPContextServerStub.GetStaticProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ServerStub.GetStaticPropertyWithMonitoredScope(String propertyName, ProxyContext proxyContext)
Microfeeds SocialRESTExceptionProcessingHandler.DoServerExceptionProcessing - SharePoint Server Exception [System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.     at Microsoft.SharePoint.Client.ServerStub.CheckRequiredResourceRight(ProxyContext proxyContext, String memberName, ResourceRight right)     at Microsoft.SharePoint.Client.ServerStub.CheckBlockedGetProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.ServerStub.SPContextServerStub.GetStaticProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ServerStub.GetStaticPropertyWithMonitoredScope(String propertyName, ProxyContext proxyContext)]
Authentication Authorization Throw UnauthorizedAccessException instead of SPUtilityInternal.Send401 for client.svc request.
CSOM Original error: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.     at Microsoft.SharePoint.Client.ServerStub.CheckRequiredResourceRight(ProxyContext proxyContext, String memberName, ResourceRight right)     at Microsoft.SharePoint.Client.ServerStub.CheckBlockedGetProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.ServerStub.SPContextServerStub.GetStaticProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ServerStub.GetStaticPropertyWithMonitoredScope(String propertyName, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.GetObjectFromPathRoot(Boolean mainRequestPath, EdmParserNode node, Boolean resourceEndpoint, MethodInformation& methodInfo)     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.GetObjectFromPath(Boolean mainRequestPath, String path, String pathForErrorMessage)     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.Process()     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.ProcessRequest()
Microfeeds SocialRESTExceptionProcessingHandler.DoServerExceptionProcessing - SharePoint Server Exception [System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.     at Microsoft.SharePoint.Client.ServerStub.CheckRequiredResourceRight(ProxyContext proxyContext, String memberName, ResourceRight right)     at Microsoft.SharePoint.Client.ServerStub.CheckBlockedGetProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.ServerStub.SPContextServerStub.GetStaticProperty(String propName, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ServerStub.GetStaticPropertyWithMonitoredScope(String propertyName, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.GetObjectFromPathRoot(Boolean mainRequestPath, EdmParserNode node, Boolean resourceEndpoint, MethodInformation& methodInfo)     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.GetObjectFromPath(Boolean mainRequestPath, String path, String pathForErrorMessage)     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.Process()     at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.ProcessRequest()]
Authentication Authorization Throw UnauthorizedAccessException instead of SPUtilityInternal.Send401 for client.svc request.

Change SharePoint site regional settings or culture info

Here is a quick script to change the regional settings for your sharepoint site.

function ChangeSiteCultureInfo() {
    [CmdletBinding()]
     Param(
      [Parameter(Mandatory=$True,
  ValueFromPipeline=$True)]
       [string]$spSiteUrl,
       [ValidateSet("en-AU","en")]
       [string]$culture = "en-AU"
       )
       BEGIN {}
    PROCESS
       {
         Write-Host "Processing site $spSiteUrl"
         $spsite  = Get-SPSite -Identity $spSiteUrl
         $rootWeb = $spsite.RootWeb 
         $cultureInfo = [System.Globalization.CultureInfo]::GetCultureInfo($culture)
         Write-Host "Curent local setting is $($rootWeb.Locale) "
         $rootWeb.Locale = $culture 
         $rootWeb.Update() 
         $rootWeb.Dispose() 
         $spsite.Dispose() 
         Write-Host "Finished Updating the locale of $spSiteUrl to $cultureInfo"
       }
       END {}
       
}
Usage:
 url_here | ChangeSiteCultureInfo

Thursday, June 19, 2014

The option for the SharePoint 2013 workflow platform is not available because the workflow service is not configured on the server

I came across this scenario where I could not create a SharePoint 2013 designer workflow on just one of the site collection.

Turns out that it is an issue with the template used for creating the site and we need to enable a couple of hidden features to enable 2013 workflows.
Here is a code snippet to help you solve this issue.
function enableWorkflowHiddenFeatures() {
    [CmdletBinding()]
     Param(
      [Parameter(Mandatory=$True,
  ValueFromPipeline=$True)]
       [string]$spSiteUrl
       )
       BEGIN {}
    PROCESS
       {
            try{
            Enable-SPFeature -Identity WorkflowServiceStore –Url $spSiteUrl
            }catch{ Write-Host $_.Message -ForegroundColor Red }
            try{
            Enable-SPFeature -Identity WorkflowTask –Url $spSiteUrl
            }catch{ Write-Host $_.Message -ForegroundColor Red }
           
       }
       END {}
       
}

  enableWorkflowHiddenFeatures -spSiteUrl siteurl


Error Message : The option for the SharePoint 2013 workflow platform is not available because the workflow service is not configured on the server. Please contact your server administrator.




Wednesday, June 18, 2014

Download source code from TFS as a ZIP file

Tip : To get a clean download of the source code as a ZIP file from TFS, Just visit the web portal, right click on the project and select download as ZIP. Too easy.



Wednesday, June 11, 2014

Adding list item context menu to initiate workflow

It is very easy to add a list item context menu to initiate a SharePoint workflow
Use designer to add a custom action and you are done.

Why blog this? there are confusing blogs out there to try and build a url to do this!






SharePoint 2013 - Triggering list item changed workflow from another workflow.

Courtesy to one of my customers, I learned yet another tip for SharePoint 2013.

Scenario : You are developing workflows in SharePoint 2013
You have enabled the setting to trigger the workflow every time a list item is changed.
You have another workflow on the same list which makes a change to the list item.
You expect the item changed workflow to be triggered.

What happens:
2013 workflows are not triggered by changes made by other workflows.
2010 workflows can be triggered by changes made by other workflows.


Tuesday, June 10, 2014

Save SharePoint list attachments to a folder

Here is a powershell script to save SharePoint list attachments to a folder

Add-PsSnapin Microsoft.SharePoint.PowerShell

function downloadListAttachments ( ){
[CmdletBinding()]
 Param(
  [Parameter(Mandatory=$True,Position=1)]
   [string]$siteURL,
   [Parameter(Mandatory=$True)]
   [string]$listName,
   [string]$Path

)

    
    $tempLocation = $Path      
    $w = Get-SPWeb $siteURL   
    $l = $w.Lists[$listName]    
    foreach ($listItem in $l.Items)
    {
          Write-Host "    Content: " $listItem.ID 
           $destinationfolder = $tempLocation         
           if (!(Test-Path -path $destinationfolder))        
                {            
                 $dest = New-Item $destinationfolder -type directory          
                }
           foreach ($attachment in $listItem.Attachments)    
           {     
               $attachment   
               $file = $w.GetFile($listItem.Attachments.UrlPrefix + $attachment)        
               $bytes = $file.OpenBinary()                
               $path = $destinationfolder + "\" + $attachment 
               Write "Saving $path" 
               $fs = New-Object System.IO.FileStream($path, "OpenOrCreate") 
               $fs.Write($bytes, 0 , $bytes.Length)    
               $fs.Close()    
           }
     }
 }
 
downloadListAttachments -siteURL "https://abc" -listName "ListName" -Path "C:\Temp"


Reference : http://bhatiaashish.blogspot.com.au/2012/08/powershell-script-to-download.html

Cannot Create Managed Metadata column through SharePoint designer

True. You cannot create managed metadata column through SharePoint designer.
Use the site settings page from UI.