Sunday, September 28, 2014

Upgrade Nintex workflows

VERIFY & CONFIGURE NINTEX WORKFLOW CONSTANTS

  1. From the home page of the upgraded site, navigate to Site Actions -> Site Settings -> Manage Workflow constants (under Nintex workflow Management)
  2. Ensure all the Nintex workflow constants (Site level and Site Collection level) are configured.


RE-PUBLISHING NINTEX WORFLOWS

  1. Access the list/document library which contain the Nintex workflow.
  2. From the ribbon, navigate to List -> Workflow settings -> Manage Workflows
  3. Open each available Nintex workflow and re-publish


Upgrade Infopath Forms

RE-PUBLISH INFOPATH FORMS

  1. Download the infopath form from the current job library, on the upgraded site.
  2. Right click on the downloaded xsn file and open the form in design mode.
  3. Click on File -> Publish -> Export Source ( to a local folder).
  4. Access the local folder where the source is stored and locate the manifest.xsf.
  5. Right click on the manifest.xsf file and open it in notepad.
  6. In the notepad, find for the url of current site and replace it with the url of the upgraded site.
  7. For example:-
  8. Replace http://apdc.oneabbott.com/showcase/workflow/BTR2020 with http://team.oneabbott.com/showcase/workflow/BTR2020
  9. Save the manifest.xsf.
  10. Right click on the manifest.xsf file and open it in the design mode.
  11. Execute the below steps for each data source added to the infopath (from the Manage Data source section).
    • Click on Manage data source link form the infopath.
    • Click on the first data source and click Modify.
    • Continue to click “Next” until the dialog display the parameters to be passed to the web service calls.
    • Verify if the url of the current site is passed as one of the parameters. If so, then replace the url with the url of the upgraded site.
  12. Save the changes to the data source and also to the manifest.xsf.
  13. Click File -> Publish -> Sharepoint library
  14. From the publish dialog select the ‘Current Job” library and publish the form.


Attach an existing content database to the farm using PowerShell script

The Mount-SPContentDatabase cmdlet attaches an existing content database to the farm. If the database being mounted requires an upgrade, this cmdlet will cause the database to be upgraded.

The default behavior of this cmdlet causes an upgrade of the schema of the database and initiates upgraded builds for all site collections within the specified content database if required. To prevent initiation of upgraded builds of site collections, use the NoB2BSiteUpgrade parameter. This cmdlet does not trigger version-to-version upgrade of any site collections.

Syntax:


Mount-SPContentDatabase [-Name] <String> [-WebApplication] <SPWebApplicationPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-AssignNewDatabaseId <SwitchParameter>] [-ChangeSyncKnowledge <SwitchParameter>] [-ClearChangeLog <SwitchParameter>] [-Confirm [<SwitchParameter>]] [-DatabaseCredentials <PSCredential>] [-DatabaseServer <String>] [-MaxSiteCount <Int32>] [-NoB2BSiteUpgrade <SwitchParameter>] [-SkipIntegrityChecks <SwitchParameter>] [-WarningSiteCount <Int32>] [-WhatIf [<SwitchParameter>]]


Example:

Mount-SPContentDatabase "MyDatabase" -DatabaseServer "MyServer" -WebApplication http://sitename


This example mounts an existing database to the sitename web application. If upgrades are required, it triggers database schema upgrade and then performs only build-to-build upgrade actions on existing site collections if required. This operation does not changed the CompatibilityLevel for existing site collections in this database.

Mount-SPContentDatabase "MyDatabase" -DatabaseServer "MyServer" -WebApplication http://sitename -NoB2BSiteUpgrade

This example mounts an existing database to the sitename web application but it prevents any site upgrades from occurring. If upgrades are required, it triggers database schema upgrades only and no build-to-build upgrade actions are performed on any site collections. This operation does not change the CompatibilityLevel for existing site collections in this database.

For More Info:

http://technet.microsoft.com/en-us/library/ff607581(v=office.15).aspx

Common SharePoint Issues & Solutions

  • PROBLEM:  When attempting to deploy a solution from Visual Studio you get an access error that includes this code – “SPUserCodeV4″
  • SOLUTION: Go to Central Administration -> System Settings. Under the “Server” heading go to “Manage Services on Server.” Look for “Microsoft SharePoint Foundation Sandboxed Code Service” and enable it. If that doesn’t work, go to the Security item in the sidebar. Under the “General Security” heading, go to “Configure service accounts.” Each service has to have a user account assigned to it. Silly. I know. Select “Windows Service – Microsoft SharePoint Foundation Sandboxed Code Service” from the dropdown, and leave YourBelovedandVeryImportantCustomer\spadmin as the account.
  • PROBLEM: When running a user control that contains UserProfileManager, you get an error that says the object cannot be found
  • SOLUTION: UserProfile Service has to be started in Central Admin. Follow the directions above, but enable both UserProfile services. You will be prompted to assign an account. Leave the account as YourBelovedandVeryImportantCustomer\spadmin. Reset IIS.
  • PROBLEM: All your list searches return null. OR a programmatic list update fails.
  • SOLUTION: Look at how you are creating your SPWeb item. If you are setting it equal to a local site, make sure the list is on that site. Here’s some handy code to get to the top level of the site without any items to dispose:
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
 {
    using (SPWeb web = site.OpenWeb())
    {
        SPList list = web.List["TheNameOfYourList"];
    }
}
*Edit: SPContext objects should not be disposed, see Jason's absolutely
correct comment below!
  • PROBLEM: On a filtered list, you cannot select a value if it is the only row.
  • SOLUTION: This one eluded me for a little while. In the “Miscellaneous” category of the web part editor panel, there is a “Send first row to connected web parts…” item. Initially this seems to just control when in the page life the data is sent. HOWEVER… In typical SharePoint non-logic logic…  this actually means “select first row by default.” The data binding event occurs regardless, except the datarow is empty if there is no selected row. Oh SharePoint, you poorly-worded rascal!
  • PROBLEM: ”File Not Found” error. OR User Profile service cannot be accessed at all.
  • SOLUTION:
  • If you are only experiencing the first issue do this:
    • Go to Central Admin > Application Management > Manage Services on Server
    • Start the following:
      • Microsoft SharePoint Foundation Web Application
      • Managed Metadata Web Service
      • SharePoint Server Search
      • If you still have a file not found error, restart IIS.
      • If you STILL have a file not found error, restart SharePoint Web Services in IIS Manager manually
      • If you are having user profile service issues, do the above, then check the following:
        • Go to Start > Administrative Tools >  Services
        • Both forefront identity managers need the following settings -
          • Make sure they are both disabled (SP will start them automatically)
          • Right click the service name and go to properties. Click the “Log On” tab. Chck “This Account” and put the farm account in. On our server its UCLA\SPAdmin, password is “password”
        • Go to Start and enter “MMC” in search. Open the management console.
          • Go to “Add snapins” in the file menu
          • Add “Certificates”
            • Select Computer account for the account
            • Select local machine for the machine
          • In The following three places, look for security certificates that begin with “Forefront”
            • Personal > Certificates
            • Trusted Root Certification Authorities > Certificates
            • Trusted People > Certificates
          • If none of the certificates exist, that’s fine. If they do, delete them.
        • Follow the steps in Spence Harbar’s post here:  To delete the current user profile service and create a new one.
        • After all this reset IIS.
        • If you still can’t connect, check Central Admin > Application Management > Service Application – Configure Service Application Associations
          • Make sure the web app has the User Profile Service proxy enabled.
After you delete your current service, you may want to delete the Application Pool so that you can create a new one with a logical name. (The default is “User Profile Services Application” and it’s a pain to have to create new pools with new names all the time, but it’s nice to just clear the old one out and try again)
  • Run PowerShell as an administrator, and enter do the following:
    • enter Add-PSSnapin Microsoft.SharePoint.PowerShell
    • enter Get-SPServiceApplicationPool
    • Copy the name of the pool you want to delete
    • enter Remove-SPServiceApplicationPool “Name of my pool”
      • Keep the quotes around the name
    • If you are still experiencing problems, you may want to restart all the associated machines.
      • If you do this, you may need to:
        • go to the your DB machine and open the sql config manager. Make sure all the services are started
        • On both the APP and WFE machines, make sure user profile service and all of the sharepoint services started back up.
      • If you get an error that the configuration database is unavailable from Central Admin, then you need to double check all the services on the DB machine from sql config manager. If you miss a single one, you may not be able to access SQL.

Clean up SharePoint User Profile Store using PowerShell

Today i had a problem in my development environment for my SharePoint Projects regarding User Profile Store. My user profile was a messed up and was not available for editing in central administration. When i searched for my profile it still there but not shown for administration.  This was a really strange behavior because a couple of days it worked well. I added various new profile properties to my user profile service application. So the recreation of User Profile Service 
Application was not an option. Deletion of orphan or corrupted user profiles is not possible using Central Administration or even using avaliable PowerShell commands.

But there is a solution using PowerShell without compiled code. Using PowerShell everything what is avaliable in the server object model is avaliable. First of all two assemblies must be referenced.
These assemblies are:

These assemblies are:

Script:

/* Load required Assemblies for SharePoint Server and User Profile */
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server”)
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server.UserProfiles”)
/* Central Adminstration URL or any Web Application*/
$url = "http://myserver:Port"
/* Create a new Context Object */
$contextWeb = New-Object Microsoft.SharePoint.SPSite("http://servername");
/* Get the right Service Context */
$ServerContext = [Microsoft.Office.Server.ServerContext]::GetContext($contextWeb);
/* create a new connection to the UserProfileManager */
$UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServerContext);
/* Ger all User Profiles */
$Profiles = $UserProfileManager.GetEnumerator();
/* Loop through user profile */
foreach ($oUser in $Profiles ) {
/* Remove Profile */
$UserProfileManager.RemoveUserProfile($oUser.item("AccountName"));
}

This script can be extended to delete only specific users from user profile information. At the end I was able to solve my problem. My User Profile was deleted and recreated on first access and due profile import. Everything worked fine.

In the old days you had to write some custom command line tool to address those batch update and deletion task. With the introduction of PowerShell to SharePoint any possible administrative task could be accomplished by just use scripting.

Those assemblies could be referenced using System.Reflection and the rest of the script is quite simple SharePoint Development. So get a context object, open profile service application get all use and delete them.

Update Mysites/UserProfile user image url

I have recently had reason to update the PictureURL property value via PowerShell in SharePoint 2013 for all users in the system.
As a result, I wrote the following PowerShell script to update the property value using string replace.

You will ideally need to run this on the server with an account with the appropriate permissions to update all user profiles.

Script:

#Set up default variables
  
  #My Site URL
  $mySiteUrl = "http://mysite/"
  
  #The part of the picture URL you are trying to find
  $currentURLValue = "http://mypersonalsite"
  
  #The value that will replace the above
 $newURLValue = "http://mysite:80"
 #The internal name for PictureURL
 $upPictureURLAttribute = "PictureURL"
 #Get site objects and connect to User Profile Manager service
 $site = Get-SPSite $mySiteUrl
 $context = Get-SPServiceContext $site
 $profileManager = New-Object   Microsoft.Office.Server.UserProfiles.UserProfileManager($context) 
 $profiles = $profileManager.GetEnumerator()
 foreach ($userProfile in $profiles) {
  if ($userProfile[$upPictureURLAttribute] -ne '') {
    
    $newPictureURL = $userProfile[$upPictureURLAttribute].toString()
    $newPictureURL  = $newPictureURL.Replace($currentURLValue, $newURLValue)
    
    write-host "Before: " $userProfile[$upPictureURLAttribute].toString() " | After: " $newPictureURL 
    
    #Get user profile and change the value - uncomment the lines below to commit the changes
    #$userProfile[$upPictureURLAttribute].Value = $newPictureURL
    #$userProfile.Commit()
  }
 }

Get the Site Collection url's for a specific Data base using Powershell script

Get-SPSite -Limit All -ContentDatabase "DBTestSiteCol" | Select URL, Owner, SecondaryOwner | Export-CSV C:\SiteInfoDB.csv -NoTypeInformation