SharePoint Warm Up with PowerShell

Every SharePoint farm needs a warm up Smile – After giving the IIS 7.5 Application Warmup a chance… I had to do it in another way…

I created a warmup script in PowerShell.

Here it is…

[Update 2011/08/03] New script with “timeout” capability: https://blog.kenaro.com/2011/08/03/sharepoint-warm-up-now-with-timeout/

 

$urls= @("http://sharepoint.local", "http://anothersharepoint.local")

New-EventLog -LogName "Application" -Source "SharePoint Warmup Script" -ErrorAction SilentlyContinue | Out-Null

$urls | % {
    $url = $_
    try {
        $wc = New-Object System.Net.WebClient
        $wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
        $ret = $wc.DownloadString($url)
        if( $ret.Length -gt 0 ) {
            $s = "Last run successful for url ""$($url)"": $([DateTime]::Now.ToString('yyyy.dd.MM HH:mm:ss'))" 
            $filename=((Split-Path ($MyInvocation.MyCommand.Path))+"lastrunlog.txt")
            if( Test-Path $filename -PathType Leaf ) {
                $c = Get-Content $filename
                $cl = $c -split '`n'
                $s = ((@($s) + $cl) | select -First 200)
            }
            Out-File -InputObject ($s -join "`r`n") -FilePath $filename
        }
    } catch {
          Write-EventLog -Source "SharePoint Warmup Script"  -Category 0 -ComputerName "." -EntryType Error -LogName "Application" `
            -Message "SharePoint Warmup failed for url ""$($url)""." -EventId 1001

        $s = "Last run failed for url ""$($url)"": $([DateTime]::Now.ToString('yyyy.dd.MM HH:mm:ss')) : $($_.Exception.Message)" 
        $filename=((Split-Path ($MyInvocation.MyCommand.Path))+"lastrunlog.txt")
        if( Test-Path $filename -PathType Leaf ) {
          $c = Get-Content $filename
          $cl = $c -split '`n'
          $s = ((@($s) + $cl) | select -First 200)
        }
        Out-File -InputObject ($s -join "`r`n") -FilePath $filename
    }
}

It will write a log file to the same directory as the script itself is stored.

Exceptions will be written to the event log!

Run it as “Scheduled Task” with the farm account credentials. – Check “Run with Highest Priviledges” !!!

Be sure this account can write to the scripts directory (for logging purpose)!

You can use this XML file for quick importing the scheduled task defintion. Therefore the script must be placed in the folder “C:Program FilesSharePoint Warmup”. The script itself must be named “sharepointwarmup.ps1”.

 <?xml version="1.0" encoding="utf-16"?>
 <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
   <RegistrationInfo>
     <Date>2011-01-26T00:00:37.2455395</Date>
     <Author>DOMAIN\ikarstein</Author>
   </RegistrationInfo>
   <Triggers>
     <CalendarTrigger>
       <Repetition>
         <Interval>PT5M</Interval>
         <Duration>P1D</Duration>
         <StopAtDurationEnd>false</StopAtDurationEnd>
       </Repetition>
       <StartBoundary>2011-01-26T00:00:37.2455395</StartBoundary>
       <Enabled>true</Enabled>
       <ScheduleByDay>
         <DaysInterval>1</DaysInterval>
       </ScheduleByDay>
     </CalendarTrigger>
   </Triggers>
   <Principals>
     <Principal id="Author">
       <UserId>DOMAIN\spfarm</UserId>
       <LogonType>Password</LogonType>
       <RunLevel>HighestAvailable</RunLevel>
     </Principal>
   </Principals>
   <Settings>
     <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
     <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
     <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
     <AllowHardTerminate>true</AllowHardTerminate>
     <StartWhenAvailable>false</StartWhenAvailable>
     <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
     <IdleSettings>
       <StopOnIdleEnd>true</StopOnIdleEnd>
       <RestartOnIdle>false</RestartOnIdle>
     </IdleSettings>
     <AllowStartOnDemand>true</AllowStartOnDemand>
     <Enabled>true</Enabled>
     <Hidden>false</Hidden>
     <RunOnlyIfIdle>false</RunOnlyIfIdle>
     <WakeToRun>false</WakeToRun>
     <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
     <Priority>7</Priority>
   </Settings>
   <Actions Context="Author">
     <Exec>
       <Command>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Command>
       <Arguments>-command ".\SharePointWarmup.ps1"</Arguments>
       <WorkingDirectory>C:\Program Files\SharePoint Warmup</WorkingDirectory>
     </Exec>
   </Actions>
 </Task>
 

1. Copy this XML code to a file, then open the “Scheduled Tasks” management console of Windows.

2. Open the “Task Scheduler Library”, right-click on it’s node. Choose “Import”.

3. Then select the XML file.

4. In the task edit dialog: Change the execution account.

5. Save the task.

6. Now enter the password of the execution account in the credential dialog.

7. Now right-click on the created scheduled task.

8. Choose “Run” to test the task.

9. Have a look into the scripts folder in file system. there must be a file named “lastrunlog.txt” – This file will contain at most 200 lines of loggin informations!

Demo project: Excel Export feature for SharePoint 2010

I’ve uploaded another private demo project. It was planned as part of an SharePoint solution I liked to create but I cannot finalize this project. So I publish this project as “stand alone” project…. You may find it useful.

You are invited to use / develop / update the project! Every help is welcome!

You find the source code here:

http://spexcelexport.codeplex.com/

The project is ALPHA!!!

The intention of the project is to create a possibility to export SharePoint lists to "plain" Excel files. Not the kind of Excel files you can download by using the SharePoint standard functionality: With that you download a "linked" Excel file that contains a permanent connection the SharePoint. It’s a query. – With my project you’ll download a real XLSX file. – And you have the possibility to store an template file that contains formatting instructions.

It’s not finished but it works! – The test project included in the source code demonstrates the feature. Use "Test List 1". (Not "Test List 2".)

Some screenshots:

This is the “Test List 1”:

image

There is a link in the upper right. This you can use to download the Excel file:

image

When you click the link you get the well known download window:

image

Clicking “Open” will open the Excel Viewer – or the “real” Excel (that I do not have on my dev machine).

image

In Excel you can resize the “C” column.

May you have seen it: There is an error in the solution: Date values are not exported correctly. There is a gap of 1 day…

The goal is to implement a Ribbon button.

See the hidden list:

image

Have a look into the single Excel file:

image

Ok… Lots of work to do Smile

Walkthrough: Create custom SharePoint 2010 list form for deployment in a Visual Studio 2010 project – PART 2

This is part 2 of my demo project about “How to create a custom list form…” –

See this post for part one:

https://blog.kenaro.com/2010/12/29/walkthrough-create-custom-sharepoint-2010-list-form-for-deployment-in-a-visual-studio-2010-project/

Here you can download the demo project as source code:

http://spcustomlistformdemo.codeplex.com/

Let’s start…

(See “ListDefinition2” in the demo project source!)

1. Create an new List Definition project item as described in the previous blog post (“Part 1”).

2. In the ASPX file of your list form be sure to add the attribute UseLegacyForm=”True” to your Form-Tag. – Like in this screenshot:

image

3. Then you need to create the field edit controls by yourself. Therefore you have to add some code to the ASPX file.

Here is some demo code. (The “ListDefinition2” based upon “Announcement List Template”…)

1:                 <WebPartPages:WebPartZone  runat="server"  FrameType="None"  ID="Main"  Title="loc:Main" 
2:                     Visible="true"> 
3:                     <ZoneTemplate> 
4:                     </ZoneTemplate> 
5:                 </WebPartPages:WebPartZone> 
6: 
7:                 <!-- ikarstein: Insert such a structure for each field you want to show on you page --> 
8:                 <table  border="0"  width="100%"> 
9:                     <tr> 
10:                         <td  class="ms-toolbar"  nowrap="nowrap"> 
11:                             <SharePoint:FormToolBar  runat="server"  ControlMode="New"  /> 
12:                         </td> 
13:                     </tr> 
14:                     <tr> 
15:                         <td> 
16:                             <span  id="part1">  <!-- ikarstein: This line is important for "Attachments" --> 
17:                                 <table  border="0"  cellspacing="0"  width="100%"> 
18:                                     <!-- ikarstein: Insert such a table row for each field / BEGIN--> 
19:                                     <tr> 
20:                                         <td  width="190px"  valign="top"  class="ms-formlabel"> 
21:                                             <h3  class="ms-standardheader"> 
22:                                                 <nobr> Title<span  class="ms-formvalidation">  *</span></nobr> 
23:                                             </h3> 
24:                                         </td> 
25:                                         <td  width="400px"  valign="top"  class="ms-formbody"> 
26:                                             <SharePoint:FormField  runat="server"  ID="field_Title"  ControlMode="New"  FieldName="Title"  /> 
27:                                             <SharePoint:FieldDescription  runat="server"  ID="field_Title_Description"  FieldName="Title" 
28:                                                 ControlMode="New"  /> 
29:                                         </td> 
30:                                     </tr> 
31:                                     <!-- karstein: END --> 
32:                                     <tr> 
33:                                         <td  width="190px"  valign="top"  class="ms-formlabel"> 
34:                                             <h3  class="ms-standardheader"> 
35:                                                 <nobr> Body</nobr> 
36:                                             </h3> 
37:                                         </td> 
38:                                         <td  width="400px"  valign="top"  class="ms-formbody"> 
39:                                             <SharePoint:FormField  runat="server"  ID="field_Body"  ControlMode="New"  FieldName="Body"  /> 
40:                                             <SharePoint:FieldDescription  runat="server"  ID="field_Body_Description"  FieldName="Body" 
41:                                                 ControlMode="New"  /> 
42:                                         </td> 
43:                                     </tr> 
44:                                     <tr> 
45:                                         <td  width="190px"  valign="top"  class="ms-formlabel"> 
46:                                             <h3  class="ms-standardheader"> 
47:                                                 <nobr> Expires</nobr> 
48:                                             </h3> 
49:                                         </td> 
50:                                         <td  width="400px"  valign="top"  class="ms-formbody"> 
51:                                             <SharePoint:FormField  runat="server"  ID="field_Expires"  ControlMode="New"  FieldName="Expires"  /> 
52:                                             <SharePoint:FieldDescription  runat="server"  ID="field_Expires_Description"  FieldName="Expires" 
53:                                                 ControlMode="New"  /> 
54:                                         </td> 
55:                                     </tr> 
56:                                     <!-- ikarstein: optionally add this table row / BEGIN --> 
57:                                     <tr  id="idAttachmentsRow"> 
58:                                         <td  nowrap="true"  valign="top"  class="ms-formlabel"  width="20%"> 
59:                                             <SharePoint:FieldLabel  ControlMode="New"  FieldName="Attachments"  runat="server"  /> 
60:                                         </td> 
61:                                         <td  valign="top"  class="ms-formbody"  width="80%"> 
62:                                             <SharePoint:FormField  runat="server"  ID="AttachmentsField"  ControlMode="New"  FieldName="Attachments"  /> 
63:                                             <script  language="javascript"  type="text/javascript"> 
64:                                               var  elm = document.getElementById("idAttachmentsTable" );
65:                                               if  (elm == null  || elm.rows.length == 0)
66:                                                 document.getElementById("idAttachmentsRow" ).style.display=< span> ;
67:                                             </script> 
68:                                         </td> 
69:                                     </tr> 
70:                                     <!-- ikarstein: END --> 
71: 
72:                                     <!-- ikarstein: Add this table for "Save" and "Cancel" buttons / BEGIN --> 
73:                                     <table  width="100%"  border="0"  cellspacing="0"> 
74:                                         <tr> 
75:                                             <td  width="99%"  class="ms-toolbar"  nowrap="nowrap"> 
76:                                                 <img  src="/_layouts/images/blank.gif"  width="1"  height="18"  /> 
77:                                             </td> 
78:                                             <td  class="ms-toolbar"  nowrap="nowrap"> 
79:                                                 <SharePoint:SaveButton  runat="server"  ControlMode="New"  ID="savebutton"  /> 
80:                                             </td> 
81:                                             <td  class="ms-separator"> 
82:                                             </td> 
83:                                             <td  class="ms-toolbar"  nowrap="nowrap"  align="right"> 
84:                                                 <SharePoint:GoBackButton  runat="server"  ControlMode="New"  ID="gobackbutton"  /> 
85:                                             </td> 
86:                                         </tr> 
87:                                     </table> 
88:                                     <!-- ikarstein: END --> 
89:                             </span> 
90:                             <SharePoint:AttachmentUpload  runat="server"  ControlMode="New"  /> 
91:                             <SharePoint:ItemHiddenVersion  runat="server"  ControlMode="New"  /> 
92:                         </td> 
93:                     </tr> 
94:                 </table> 
95: 
96: 

(You see my comments inline ?! Not much, I know…)

Behind  the “<WebPartZone>” tag add the HTML code.

You can add input fields by using this snipped:

1:                                     <!-- ikarstein: Insert such a table row for each field / BEGIN--> 
2:                                     <tr> 
3:                                         <td  width="190px"  valign="top"  class="ms-formlabel"> 
4:                                             <h3  class="ms-standardheader"> 
5:                                                 <nobr> Title<span  class="ms-formvalidation">  *</span></nobr> 
6:                                             </h3> 
7:                                         </td> 
8:                                         <td  width="400px"  valign="top"  class="ms-formbody"> 
9:                                             <SharePoint:FormField  runat="server"  ID="field_Title"  ControlMode="New"  FieldName="Title"  /> 
10:                                             <SharePoint:FieldDescription  runat="server"  ID="field_Title_Description"  FieldName="Title" 
11:                                                 ControlMode="New"  /> 
12:                                         </td> 
13:                                     </tr> 
14:                                     <!-- karstein: END -->
15: 

Of course you can change the page design. You only need the tag “<SharePoint:FormField>”, optionally “<SharePoint:FieldDescription>”. In every case the “FieldName” Attribute represents the List field the input field is connected with.

You do not need to create any Code Behind!

Just add "<SharePoint:GoBackupButton>” for cancel and “<SharePoint:SaveButton>” for submit.

Furthermore you have some controls for adding attachments to your List item.

AND: It’s the same for “Edit” list form. You only need to change the attributes “ControlMode” to “Edit”… Totally easy, isn’t it?

4. Deploy it and have a look…

Error while executing the SharePoint 2010 PowerShell cmdlet Mount-SPContentDatabase: “Exception of type ‘Microsoft.SharePoint.Upgrade.SPUpgradeException’ was thrown.”

Mount-SPContentDatabase : Exception of type 'Microsoft.SharePoint.Upgrade.SPUpgradeException' was thrown.
At D:TempAttach_OldContentDBs_DoIt.ps1:63 char:28
+              Mount-SPContentDatabase <<<<  -WebApplication $webapp -Name $thisdb
    + CategoryInfo          : InvalidData: (Microsoft.Share...ContentDatabase:SPCmdletMountContentDatabase) [Mount-SPContentDatabase], SPUpg
   radeException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletMountContentDatabase

Have a look into the SQL Server Management Studio. – The content database is read only. That’s the problem Smile

SharePoint 2010 Help doesn’t work after migration

I had to migrate a MOSS 2007 farm to SharePoint 2010. – After migration the SharePoint Help did not work. (It’s the button upper right on a SharePoint site.)

A popup window appeared and I got an empty site with the message “Help not available” (or something like that: It was a german site so the error message was german…)

I tried a new created web application with a Team Site collection. There the help does work as expected.

Then I had a look into the Windows Event Log. There I found a related error. The web application pool account of my migrated web application did not has access to the Admin Content database. But the application pool account of the new created web application was enabled to access this database. – After adding the application pool account of my migrated web application as “db_owner” the help was shown as expected.

(I have no screenshots of that. Sorry. But I think, that can be reproduced easily by removing the application pool account from the Admin Content database.)

Missing “View in Browser” and “Edit in Browser” in the context menu of Excel files in a SharePoint 2010 document library…

You have installed the Office Web Apps on your SharePoint 2010 server. Now you are missing the menu entries “View in Browser” and “Edit in Browser”.

You create a new Excel file in Excel 2007 or 2010, upload it and… there are the menu entries… maybe…

This was the situation of my customer yesterday. He tried to open documents in the Office Web Apps after migration from MOSS to SharePoint 2010. Everything seems to work: Word Web App, PowerPoint Web App, OneNote Web App…

I created a new site collection and uploaded a Excel file (XLSX). – The menu entries appeared.

Then I uploaded a document I’ve downloaded before from the migrated site collection. The menu entries were gone… – THEN I REALIZED: To new document was in OpenXML format (Excel 2007, Excel 2010), the migrated documents in native Excel format of Excel 97…2003. Thats the problem: Only OpenXML Excel files can be viewed an edited in the browser!!! – Thats diffrent from Word Web App and PowerPoint Web App.

I’m looking around on the Microsoft web site, but till now I’ve not found an official comment on that. But this seems to be “behavior by design”… Don’t waste as much time as I’ve wasted with that!

Error while connecting to a SharePoint 2010 web site in SharePoint Designer 2010

 

Today I got this error:

SPDError-3

(“The server could not complete your request. For more specific information, click the Details button.”)

I clicked the “Details” button as commanded.

SPDError-4

(“Below is the message that the server returned. For more information, contact your Internet service provider or web server administrator.”)

I asked myself (because I’m the web server administrator in this case) – I had no answer for me.

I clicked: “OK” and “OK” and got:

 SPDError-5

(‘An error occurred while trying to fetch data from your SharePoint site. Unexpected response from the server. The content type type of the response is “” This status code is “OK”.’)

“OK”??????????? Okay…

I read the event viewer log:

SPDError-1

WebHost failed to process a request.
 Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/64923656
 Exception: System.ServiceModel.ServiceActivationException: The service '/_vti_bin/client.svc' cannot be activated due to an exception during compilation.  The exception message is: Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service.. ---> System.NotSupportedException: Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service.
   at System.ServiceModel.Channels.HttpChannelListener.ApplyHostedContext(VirtualPathExtension virtualPathExtension, Boolean isMetadataListener)
   at System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener[TChannel](BindingContext context)
   at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[TChannel]()
   at System.ServiceModel.Channels.MessageEncodingBindingElement.InternalBuildChannelListener[TChannel](BindingContext context)
   at System.ServiceModel.Channels.WebMessageEncodingBindingElement.BuildChannelListener[TChannel](BindingContext context)
   at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[TChannel]()
   at System.ServiceModel.Channels.Binding.BuildChannelListener[TChannel](Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters)
   at System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession)
   at System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
 Process Name: w3wp
 Process ID: 7248

…………….. It was my mistake. ………………………….

An hour before I configured my SharePoint Site to use KERBEROS. – In the IIS I configured the Web application “Authentication” settings: I choose the provider “Negotiate” but I also removed “NTLM”. This was my fault.

This is the correct setting:

SPDError-6

The definitive guide of How to configure the SharePoint 2010 User Profile Service Application

I took me hours and hours to get to User Profile Service Application working.

These are the steps I’ve done in some scenarios.

Especial to migrate an SharePoint 2007 profile database to SharePoint 2010.

0. The databases for the User Profile Service Application must run on the standard instance of SQL Server. NEVER use a named instance. – Always use SQL Aliases instead!!!

1. (Skip this next step if you don’t need to migrate.) Backup the Shared Service Provider Database of your MOSS farm.

2. Restore the farm to your destination SQL Server instance and with the destination database name, e.g. “SP_SvcApp_UserProfile_Profiles”.

(In the MOSS farm the database was named “MOSS_SSP_Config” !!! –> It’s the configuration database of the Shared Service Provider.)

3. Create the User Profile Service Application with this PowerShell script:

#region Check x64 host
if( [System.IntPtr]::Size -ne 8) {
  Write-Error "Please use a x64 PowerShell host!"
  return
}
#endregion

#region Load SharePoint SnapIn and DLL
  Remove-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

  [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  | out-null    

  #Check available SharePoint Cmdlets
  if( (Get-Command -Noun SPWeb*) -eq $null ) {
    Write-Error "SharePoint SnapIn not loaded. SharePoint cmdlets missing!"
    return
  }
#endregion

cls

######################################################################################################

# Profile database in my MOSS farm : MOSS_SSP_CONFIG 

#---------------------------------------------------------------------------
# Settings

$farmname = "SP"

$spfarmuser='DOMAINsp_farm'
$spfarmpwd='passwort1#'
$mysiteHostLocation = "http://mysite.sharepoint.local"
$mysiteManagedPath = "/personal"

#---------------------------------------------------------------------------

$spfarmcredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $spfarmuser, (ConvertTo-SecureString $spfarmpwd -AsPlainText -force)
$userprofileAppProfileDBName =("{0}_SvcApp_UserProfile_Profiles" -f $farmname)
$userprofileAppProfileSyncDBName =("{0}_SvcApp_UserProfile_Sync" -f $farmname)
$userprofileAppProfileSocialDBName =("{0}_SvcApp_UserProfile_Social" -f $farmname)
$svcAppPool=("{0}_AppPool_UserProfile" -f $farmname)

# Create application pool
$appPool = (Get-SPServiceApplicationPool -Identity $svcAppPool -ErrorAction SilentlyContinue)
if( $appPool -eq $null ) {
  $appPool = (New-SPServiceApplicationPool -Account $spfarmuser -Name $svcAppPool)
}

$userProfileSvcApp = (Get-SPServiceApplication  | ? { $_.TypeName -eq "User Profile Service Application" })

# Create service application
if( $userProfileSvcApp -eq $null ) {
  $userProfileSvcApp = (New-SPProfileServiceApplication -ApplicationPool $appPool -MySiteHostLocation  $mysiteHostLocation `
                          -MySiteManagedPath $mysiteManagedPath -ProfileDBName $userprofileAppProfileDBName `
                          -ProfileSyncDBName $userprofileAppProfileSyncDBName -SocialDBName $userprofileAppProfileSocialDBName `
                          -Name "User Profile Service Application" -SiteNamingConflictResolution "None" -Verbose)
}

# Create application proxy
$proxy = (Get-SPServiceApplicationProxy | ? { $_.Name -like "User Profile Service Application Proxy" } )
if( $proxy -eq $null ) {
  $proxy = (New-SPProfileServiceApplicationProxy -DefaultProxyGroup -Name "User Profile Service Application Proxy" -ServiceApplication $userProfileSvcApp)
}

 

During the creation of the User PRofile Service Application the MOSS database will be migrated!!

If you did no restore previously the profile database will be created in this step.

4. The farm account must be local admin on the farm server.

5. Go into the SQL Server Management Studio.

6. Set the farm account – in my example “sp_farm” – as SYSADMIN in your SQL Server instance.

7. Edit the User Logins for the (migrated) profile database.

The farm account should exist as login. – If not: add the account as “db_owner”.

Important: Set the schema for the farm account to “dbo”!

8. In the Windows Services Manager (Server Manager): restart a services that has the farm account as identity. OR restart the server!

9. Now: Log on locally with the farm account!! – Yes: logon with the farm account!

10. As farm account: go into the Central Administration –> Manage Services on Server –> Start the User Profile Synchronization service!

11. WAIT!

12. Press F5 on the “Managa Services on Server” page. Maybe wait some more Smile. Have a look into the the SharePoint log. You should find lots of message. Search for “ILM” (using ULSViewer of course).

13. Sometimes – if you are a lucky person – the “User Profile Synchronization” service is startet. – Maybe not. In this case: Start over! – Last time it took me three times to get it working!

14. At the end: remove the farm account from the SYSADMIN group!

[Update / 01/26/2011]

15. Don’t forget to reset the Security Settings (“Administrators”) for the User Profile Service Application after you recreated them. – Go into the Central Administration -> Manage Service Applications -> select your User Profile Service Application -> click “Administrators” in the Ribbon. – You may find this empty!!! This is not correct. Insert here at least the farm account with “Full Control” permissions. And don’t forget to insert the search crawl account with “Retrieve People Data for Search Crawlers” permissions. Otherwise your People Search will not work!

Please give me feedback on this! – The configuration of the User Profile Services Application is a incredible mess.

(Another) error opening a document in a Office Web App of SharePoint 2010: “PowerPoint Web App encountered an error. Please try again.”

… on the SharePoint 2010 with german system language of my customer the message text was “Fehler bei PowerPoint Web App. Wiederholen Sie den Vorgang.”

PowerPointWebAppError-1

In the SharePoint log I found this lines:

PowerPointWebAppError-2

First: “Could not find default ServiceProxy or it does not implement IWacServiceApplicationProxy”

Second: “Unhandled exception caught when executing web method handler: System.NullReferenceException”

The Solution:

There was a missing setting for the Service Application Default Proxy Group

Go to: Central Administration –> Application Management –> Configure service application association  ==> click the link (e.g. “default”) in column “Application Proxy Group” of your web application.

You should see something like that:

PowerPointWebAppError-3

Check the missing proxy. Click OK. That’s it…

Failed to open a document with a Office Web App in SharePoint 2010

Today I got this error while opening a Word document stored in a SharePoint library. This document should be opened in the Word Web App. – IT WAS A DOCUMENT IN A MIGRATED CONTENT DATABASE…

WordWebApp-Error-01

(“Word Web App cannot open this document for viewing because of an unexpected error. To view this document, open it in Microsoft Word.”)

I looked into SharePoint log and found this error message:

WordWebApp-Error-02

(“Requesting item that was not generated”)

Then I looked into Windows Event Viewer and found this critical error event:

(“SQL Database ‘…’ on SQL Server instance ‘…’ not found. Aditional error information from SQL Server is included below.” … Followed by some messages in german (because the SQL Servers language is german)… “Fehler bei der Anmeldung” which means: “Access Denied”

WordWebApp-Error-03

Solution:

The Service Account of the SharePoint Web Services System needs “db_owner” rights on the migrated content databases!!! (You see this account in the event log message!!!)