Saturday, 23 July 2016

Nintex Workflow (401: Unauthorized).

Symptom and Cause

Nintex workflow 2013 error message while publishing the workflow:-

Error Exception calling "PublishFromNWFXml" with "4" argument(s): "The request failed with HTTP status 401: Unauthorized."

Error Log:-
Access Denied. Exception: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)), StackTrace: 
 at Microsoft.SharePoint.Library.SPRequestInternalClass.OpenWeb(String bstrUrl, String& pbstrServerRelativeUrl, String& pbstrTitle, String& pbstrDescription, String& pbstrTitleResourceId, String& pbstrDescriptionResourceId, Guid& pguidID, DateTime& pdtTimeCreated, String& pbstrRequestAccessEmail, UInt32& pwebVersion, Guid& pguidScopeId, UInt32& pnAuthorID, UInt32& pnLanguage, UInt32& pnLocale, UInt16& pnTimeZone, Boolean& bTime24, Int16& pnCollation, UInt32& pnCollationLCID, Int16& pnCalendarType, Int16& pnAdjustHijriDays, Int16& pnAltCalendarType, Boolean& pbShowWeeks, Int16& pnFirstWeekOfYear, UInt32& pnFirstDayOfWeek, Int16& pnWorkDays, Int16& pnWorkDayStartHour, Int16& pnWorkDayEndHour, Int16& pnMeetingCount, Int32& plFlags, Boolean& bConnectedToPortal, String& pbstrPortalUrl, String& pbstrPortalName, Int32& plWebTemplateId, Int16& pnProvisionConfig, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrThemedCssFolderUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, UInt64& ppermMask, Boolean& bUserIsSiteAdmin, Boolean& bHasUniquePerm, Guid& pguidUserInfoListID, Guid& pguidUniqueNavParent, Int32& plSiteFlags, DateTime& pdtLastContentChange, DateTime& pdtLastSecurityChange, String& pbstrWelcomePage, Boolean& pbOverwriteMUICultures, Boolean& pbMUIEnabled, String& pbstrAlternateMUICultures, Int32& plSiteSchemaMajorVersion, Int32& plSiteSchemaMinorVersion, Int32& plSiteSchemaBuildVersion, Int32& plSiteSchemaRevisionVersion, Int32& puiVersion, Int16& pnClientTag, Boolean& pfIsEvalSite, Guid& pgSourceSiteId, DateTime& pdtExpirationDate, Guid& pgEvalSiteId, Guid& pguidAppProductId, String& pbstrRemoteAppUrl, String& pbstrOAuthAppId, String& pbstrAppDatabaseName, Guid& pgAppDatabaseServerReferenceId, String& pbstrAppDatabaseTargetApplicationId, String& pbstrAppWebDomainId, Int32& plUpgradeFlags, DateTime& pdtReminderDate, UInt64& pmaskDeny)   
 at Microsoft.SharePoint.Library.SPRequest.OpenWeb(String bstrUrl, String& pbstrServerRelativeUrl, String& pbstrTitle, String& pbstrDescription, String& pbstrTitleResourceId, String& pbstrDescriptionResourceId, Guid& pguidID, DateTime& pdtTimeCreated, String& pbstrRequestAccessEmail, UInt32& pwebVersion, Guid& pguidScopeId, UInt32& pnAuthorID, UInt32& pnLanguage, UInt32& pnLocale, UInt16& pnTimeZone, Boolean& bTime24, Int16& pnCollation, UInt32& pnCollationLCID, Int16& pnCalendarType, Int16& pnAdjustHijriDays, Int16& pnAltCalendarType, Boolean& pbShowWeeks, Int16& pnFirstWeekOfYear, UInt32& pnFirstDayOfWeek, Int16& pnWorkDays, Int16& pnWorkDayStartHour, Int16& pnWorkDayEndHour, Int16& pnMeetingCount, Int32& plFlags, Boolean& bConnectedToPortal, String& pbstrPortalUrl, String& pbstrPortalName, Int32& plWebTemplateId, Int16& pnProvisionConfig, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrThemedCssFolderUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, UInt64& ppermMask, Boolean& bUserIsSiteAdmin, Boolean& bHasUniquePerm, Guid& pguidUserInfoListID, Guid& pguidUniqueNavParent, Int32& plSiteFlags, DateTime& pdtLastContentChange, DateTime& pdtLastSecurityChange, String& pbstrWelcomePage, Boolean& pbOverwriteMUICultures, Boolean& pbMUIEnabled, String& pbstrAlternateMUICultures, Int32& plSiteSchemaMajorVersion, Int32& plSiteSchemaMinorVersion, Int32& plSiteSchemaBuildVersion, Int32& plSiteSchemaRevisionVersion, Int32& puiVersion, Int16& pnClientTag, Boolean& pfIsEvalSite, Guid& pgSourceSiteId, DateTime& pdtExpirationDate, Guid& pgEvalSiteId, Guid& pguidAppProductId, String& pbstrRemoteAppUrl, String& pbstrOAuthAppId, String& pbstrAppDatabaseName, Guid& pgAppDatabaseServerReferenceId, String& pbstrAppDatabaseTargetApplicationId, String& pbstrAppWebDomainId, Int32& plUpgradeFlags, DateTime& pdtReminderDate, UInt64& pmaskDeny).

Resolution

There are many ways to getting the above error message in Nintex workflow 2013:-
  • Check the Nintex workflow content database permissions.
  • Site Collection content databae have properly mapped with Nintex content database.
  • Refresh the SharePoint authentication process like example: Ping Federate authentication.


Thursday, 21 July 2016

Failed to start workflow. The profile for the user is a temporary profile.

Symptom and Cause

Nintex workflow 2013 is not triggered and getting error message “Failed to start workflow. The profile for the user is a temporary profile.” Nintex workflow internally working with w3wp process for the application pool (service Account).
In that case indicates that the application pool profile for the w3wp web service does not exist on servers.

Error Log:-
Nintex.Workflow.NWActionExecutionException: Failed to start workflow. ---> System.Security.Cryptography.CryptographicException: The profile for the user is a temporary profile.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) at System.Security.Cryptography.Utils.get_StaticDssProvHandle()
at System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSAParameters parameters) at System.Security.Cryptography.DSA.FromXmlString(String xmlString) at Nintex.Workflow.Licensing.License.YR4=(String Yh4=, String Yx4=, DateTime ZB4=) at Nintex.Workflow.Licensing.License..ctor()
at Nintex.Workflow.Licensing.License.Zh4=()
at Nintex.Workflow.Licensing.License.Zx4=(Boolean aB4=) at Nintex.Workflow.Licensing.License.IsLicenseValid(LicenseCheckType options, SPWeb web, String& invalidReason) at Nintex.Workflow.Activities.ReportingHeaderActivity.Execute(ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
at System.Workflow.Runtime.Scheduler.Run() -
-- End of inner exception stack trace --- (Build:3080)


Resolution

Generate a local profile (Service Account) on servers –running w3wp process for the application pool.

More Information

I've found the following blogs:-

See section "User Profiles" in the below blog

Thursday, 7 January 2016

Delete all SharePoint Groups for list level using PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$web = Get-SPWeb http://site-name/Inst/site
$list = $web.Lists.TryGetList("Deleted Documents")
if($list.HasUniqueRoleAssignments -eq $False)
{
$list.BreakRoleInheritance($True)
}
[Microsoft.SharePoint.SPRoleAssignmentCollection] $spRoleAssignments=$list.RoleAssignments

for([int] $a=$spRoleAssignments.Count-1; $a -ge 0;$a--)
{
$spRoleAssignments.Remove($a);
}
$web.Dispose()

Tuesday, 24 February 2015

Run reusable workflow for all list Items in SharePoint using PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
# URL of the Site
$web = Get-SPWeb -Identity https://sharepointsrv/site1
$manager = $web.Site.WorkFlowManager
# Name of the list
$list = $web.Lists["Shared Documents"]
# Name of the Workflow
$assoc = $list.WorkflowAssociations.GetAssociationByName("On Item Created","en-US")
$data = $assoc.AssociationData
$items = $list.Items
foreach($item in $items) {
        $wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
}
$manager.Dispose()
$web.Dispose()

Saturday, 21 February 2015

Update SharePoint list or library view using PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$GetAllWebDetails = "D:\[Location]\GetAllWebDetails.csv"
#---------------Please do not delete-------
Start-SPAssignment -Global #Start Assignment for disposal
$Time=Get-Date
Write-Host Start Time:$Time -ForegroundColor Yellow `n
$ListNameStore=@("Management","ABC","123")
function UpdateViews($webUrl)
{
    $web = Get-SPWeb -Identity $webUrl
    Write-Host $web.Url
    $webLists = $web.Lists
    for ($i = 0; $i -lt $webLists.Count; $i++)
    {
        $list = $web.Lists[$i];
        foreach($stlist in $ListNameStore) {
            if($list.Title -eq $stlist ) {
          
                $column = $list.Fields["Column Name"]
                if($column -ne $null){  
                    $column.Hidden = $false  
                    $column.ReadOnlyField = $false  
                    $column.Update()
                    $list.Fields.Delete($column) 
                    $list.Update()
                }
              }
          }
    }
   
    $Web.Dispose()
}

IMPORT-CSV $GetAllWebDetails |
  ForEach-Object {
    $WebUrl=$_.WebUrl
      Write-Host  Update Views is Started in $WebUrl -ForegroundColor Green 
    $site = Get-SPSite $WebUrl
    foreach($web in $site.AllWebs){
        UpdateViews  $web.Url
    }
    Write-Host  Update Views is completed in $WebUrl -ForegroundColor Green
}
$EndTime = Get-Date
Write-Host `n End Time:$EndTime -ForegroundColor Yellow

Attach Lookup Columns to document and document set content types using PowerShell

Below is the PowerShell code for adding user in Attach Lookups To Document And DocSet Content Types.
- Need to change some configure details in script.
- Need to chagne in CSV file like ContentType, SiteColumn and ColumnSetting.


Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
Function CheckColumnExistsOnContentType{
Param($ContentType, $ColumnName)      
$Fields = $ContentType.Fields | ? {$_.InternalName -eq $ColumnName}
Write-Host $ColumnName $Fields
If($Fields -eq $Null){
Return $false
}
Else{
Return $true}      
}
 
    $SPSite = Get-SPSite -Identity http://serverName/
    $Web = $SPSite.RootWeb
    $Create = Import-Csv -path "C:\[location]\AttachLookupsToDocumentAndDocSetContentTypes.csv"
$Create
    ForEach($Row in $Create){
        $CT = $Web.ContentTypes[$Row.ContentType];
        $FieldAdd = $Web.Fields.GetFieldByInternalName($Row.SiteColumn)
  $ColumnExists = CheckColumnExistsOnContentType -ContentType $CT -ColumnName $FieldAdd
  if($ColumnExists -eq $True)
  {
   Write-Host "Attached Column" $FieldAdd.InternalName "to" $CT.name -ForegroundColor Cyan
   $FieldLink = New-Object Microsoft.SharePoint.SPFieldLink($FieldAdd)
   If($($_.'ColumnSetting') -eq "Hidden"){
    $FieldLink.Required = $false
    $FieldLink.Hidden = $true
   }
   ElseIf(($($_.'ColumnSetting') -eq "Required")){
        $FieldLink.Required = $true
   }
   Else{
       $FieldLink.Required = $false
   }
   $CT.FieldLinks.Add($FieldLink)
   $CT.Update($true)
   $Web.Update()
   $Web.Dispose()
   Write-Host " Column is added in Content Type" -ForegroundColor Green
  }
}

Flush Blob Cache in SharePoint 2013

Running in all the servers.


Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$webApp = Get-SPWebApplication http://ServerName.com
[Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)
Write-Host "Flushed the BLOB cache for:" $webApp