How to fix broken images after mySite URL change in SharePoint 2010?

Here is a small PowerShell script to fix the pictureurl for all userprofiles after changing the mySite Url:

$mySiteWebapplicationUrl = "https://mysite.normanbauer.com/"
#current Url of your mySite website

$mySiteOldUrlValue = "http://mysitetest:80/"
#former Url where your pictures do not reside any more

$mySiteNewUrlValue = "https://mysite.normanbauer.com:443/"
#current Url where your images can be found now

$mySite = Get-SPSite $mySiteWebapplicationUrl
$SPServiceContext = Get-SPServiceContext $mySite
$userProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($SPServiceContext)
$userProfiles = $profileManager.GetEnumerator()

foreach ($userProfile in $userProfiles)
{
  #if pictureurl is not empty replace the old url part with the new one
  if ($userProfile["PictureURL"] -ne '')
  {
    $oldPictureUrl = $userProfile["PictureURL"].toString()
    $newPictureUrl = $oldPictureUrl.Replace($mySiteOldUrlValue, $mySiteNewUrlValue)
    write-host "oldPictureUrl = " $oldPictureUrl " --> newPictureUrl = " $newPictureUrl
    $userProfile["PictureURL"].Value = $newPictureUrl
    $userProfile.Commit()
  }
}

Creating profile synchronization connections in Sharepoint 2010 fails with error

When creating profile synchronization connections in Sharepoint 2010, for example as a part of configuring the profile synchronization service (http://technet.microsoft.com/en-us/library/ee721049.aspx) you may receive one of the following errors:

Error
Unable to process Create message
Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: {GUID}
Date and Time: {timestamp}

Error
Access to the requested resource(s) is denied
Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: {GUID}
Date and Time: {timestamp}

Normally you’ll get the “Access to the requested resource(s) is denied” error when trying to create a connection but the profile synchronization user (this is the farm account user you used to start the User Profile Synchronization service) does not have administrative rights on the profile synchronization server (this is the server you selected for Profile Synchronization Instance when creating the User Profile Service application). You can simply solve this problem by adding the user to the local administrators group temporarily.

The “Unable to process Create message” error happens when you tried to create a synchronization connection earlier and trying to create a new one with the same name. This occurs, for example, when you retry the creation with the same name after the “Access to the requested resource(s) is denied” error appeared on the last try. Simply choose another name and confirm that the User Profile Synchronization service user has at least local administrator rights on the profile synchronization server.

How to get detailed information on Windows boot and shutdown performance in PowerShell?

In Windows 7 administrators have the possibility to monitor boot and shutdown performance by reviewing event logs. The most common one is located at Event Viewer > Application and Services Logs > Microsoft > Windows > Diagnostics-Performance > Operational. Events with an ID of 100 for boot up and 200 for shutdown will give you some basic information on the general tab, for example, when did the last boot up or shutdown happen and how long took it to complete and more detailed information on the Details tab.

On the Details tab you can find even more. Here is how to get this information programatically with the help of powershell. Run the following commands from an elevated powershell:

$bootevents = Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Diagnostics-Performance/Operational"; id=100}
$bootevent = 1$bootevents[0].ToXml()
$bootevent.Event.EventData.Data

$shutdownevents = Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Diagnostics-Performance/Operational"; id=200}
$shutdownevent = 1$shutdownevents[0].ToXml()
$shutdownevent.Event.EventData.Data

These upper 3 lines will get all events from the named logfile with the event id 100. Afterwards in converts the first result to xml, which now can be used in different ways. At this time we just want to print it on the screen. The lower 3 lines will do the same for shutdown events with event id 200.

This is the boot result for my computer:

Name                                    #text
----                                    -----
BootTsVersion                           2
BootStartTime                           2012-01-10T07:33:36.656000300Z
BootEndTime                             2012-01-10T07:35:43.438676400Z
SystemBootInstance                      167
UserBootInstance                        122
BootTime                                78563
MainPathBootTime                        30263
BootKernelInitTime                      28
BootDriverInitTime                      1521
BootDevicesInitTime                     1809
BootPrefetchInitTime                    0
BootPrefetchBytes                       0
BootAutoChkTime                         0
BootSmssInitTime                        7424
BootCriticalServicesInitTime            534
BootUserProfileProcessingTime           4625
BootMachineProfileProcessingTime        10802
BootExplorerInitTime                    2383
BootNumStartupApps                      17
BootPostBootTime                        48300
BootIsRebootAfterInstall                false
BootRootCauseStepImprovementBits        0
BootRootCauseGradualImprovementBits     0
BootRootCauseStepDegradationBits        0
BootRootCauseGradualDegradationBits     0
BootIsDegradation                       false
BootIsStepDegradation                   false
BootIsGradualDegradation                false
BootImprovementDelta                    0
BootDegradationDelta                    0
BootIsRootCauseIdentified               false
OSLoaderDuration                        1026
BootPNPInitStartTimeMS                  28
BootPNPInitDuration                     1990
OtherKernelInitDuration                 1006
SystemPNPInitStartTimeMS                2990
SystemPNPInitDuration                   1340
SessionInitStartTimeMS                  4337
Session0InitDuration                    5181
Session1InitDuration                    1192
SessionInitOtherDuration                1050
WinLogonStartTimeMS                     11761
OtherLogonInitActivityDuration          691
UserLogonWaitDuration                   8463

And here is the shutdown result:

Name                                    #text
----                                    -----
ShutdownTsVersion                       1
ShutdownStartTime                       2012-01-07T15:06:38.501239300Z
ShutdownEndTime                         2012-01-07T15:07:03.559344800Z
ShutdownTime                            25058
ShutdownUserSessionTime                 2728
ShutdownUserPolicyTime                  37
ShutdownUserProfilesTime                84
ShutdownSystemSessionsTime              20852
ShutdownPreShutdownNotificationsTime    15732
ShutdownServicesTime                    5007
ShutdownKernelTime                      1477
ShutdownRootCauseStepImprovementBits    0
ShutdownRootCauseGradualImprovementBits 0
ShutdownRootCauseStepDegradationBits    0
ShutdownRootCauseGradualDegradationBits 0
ShutdownIsDegradation                   false
ShutdownTimeChange                      0

Have a look at this blog post to learn how to push this data into a SQL database with powershell.

Apps won’t open after update to iOS 5

A few months ago I wrote a blog post about apps not opening any more after updating Apple iOS from 4.3.2 or below to 4.3.3 or higher. Now that iOS 5 has been released this problem seems to be still persistent and hasn’t been fixed in iOS 5. While updating your iPhone, iPod or iPad from 4.3.3 or higher to iOS 5 does not seem to be a problem, updating from earlier versions indeed does. So again: when your 3rd party apps like Facebook, WhatsApp, Amazon, eBay & Co. do not open any more after updating, simply try one of these methods:

  • Open the app store and update any app that has updates available, or
  • Download any free app from the app store

After successfully logging in to your account all 3rd party apps should open as usual…

How to change BitLocker recovery password with vbScript?

Related to my last post about how to change BitLocker recovery password from an elevated command prompt here is how you can achieve the same result with vbScript and WMI. This script is from Microsoft TechNet: BitLocker Drive Encryption Operations Guide: Recovering Encrypted Volumes with AD DS.

' Target drive letter
strDriveLetter = "c:"

' Target computer name
' Use "." to connect to the local computer
strComputerName = "."

' --------------------------------------------------------------------------------
' Connect to the BitLocker WMI provider class
' --------------------------------------------------------------------------------

strConnectionStr = "winmgmts:" _
                 & "{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" _
                 & strComputerName _
                 & "\root\cimv2\Security\MicrosoftVolumeEncryption"

On Error Resume Next 'handle permission errors

Set objWMIService = GetObject(strConnectionStr)

If Err.Number <> 0 Then
     WScript.Echo "Failed to connect to the BitLocker interface (Error 0x" & Hex(Err.Number) & ")."
     Wscript.Echo "Ensure that you are running with administrative privileges."
     WScript.Quit -1
End If

On Error GoTo 0

strQuery = "Select * from Win32_EncryptableVolume where DriveLetter='" & strDriveLetter & "'"
Set colTargetVolumes = objWMIService.ExecQuery(strQuery)

If colTargetVolumes.Count = 0 Then
    WScript.Echo "FAILURE: Unable to find BitLocker-capable drive " &  strDriveLetter & " on computer " & strComputerName & "."
    WScript.Quit -1
End If

' there should only be one volume found
For Each objFoundVolume in colTargetVolumes
    set objVolume = objFoundVolume
Next

' objVolume is now our found BitLocker-capable disk volume

' --------------------------------------------------------------------------------
' Perform BitLocker WMI provider functionality
' --------------------------------------------------------------------------------

' Add a new recovery password, keeping the ID around so it doesn't get deleted later
' ----------------------------------------------------------------------------------

nRC = objVolume.ProtectKeyWithNumericalPassword("Recovery Password Refreshed By Script", , sNewKeyProtectorID)

If nRC <> 0 Then
     WScript.Echo "FAILURE: ProtectKeyWithNumericalPassword failed with return code 0x" & Hex(nRC)
     WScript.Quit -1
End If

' Removes the other, "stale", recovery passwords
' ----------------------------------------------------------------------------------

nKeyProtectorTypeIn = 3 ' type associated with "Numerical Password" protector

nRC = objVolume.GetKeyProtectors(nKeyProtectorTypeIn, aKeyProtectorIDs)

If nRC <> 0 Then
     WScript.Echo "FAILURE: GetKeyProtectors failed with return code 0x" & Hex(nRC)
     WScript.Quit -1
End If

' Delete those key protectors other than the one we just added.

For Each sKeyProtectorID In aKeyProtectorIDs
     If sKeyProtectorID <> sNewKeyProtectorID Then
          nRC = objVolume.DeleteKeyProtector(sKeyProtectorID)
          If nRC <> 0 Then
               WScript.Echo "FAILURE: DeleteKeyProtector on ID " & sKeyProtectorID & " failed with return code 0x" & Hex(nRC)
               WScript.Quit -1
          Else
               ' no output
               'WScript.Echo "SUCCESS: Key protector with ID " & sKeyProtectorID & " deleted"
          End If
     End If
Next

WScript.Echo "A new recovery password has been added. Old passwords have been removed."

' - some advanced output (hidden)
'WScript.Echo ""
'WScript.Echo "Type ""manage-bde -protectors -get " & strDriveLetter & " -type recoverypassword"" to view existing passwords."

How to change BitLocker recovery password?

Sometimes you need to give a BitLocker recovery password to one of your customers. For example when you cannot access the computer remotely. It also happens that passwords get revealed accidentally or intentionally. While either scenario can be a security lack you may want to change the recovery password of a certain computer.

To do so, you’ll need to open an elevated command prompt. With manage-bde.exe (BitLocker Drive Encryption: Configuration Tool) you can manage to change such recovery passwords.

First get a list of recovery passwords for the desired partition by typing:

manage-bde.exe c: -protectors -get -type recoverypassword

This step is not really necessary unless you have more protectors of a certain type. If so you’ll need to copy the ID of the protector you want to change.

After that delete the protector. You can do this by using the id:

manage-bde.exe c: -protectors -delete -id {ID}

or by using the type:

manage-bde.exe c: -protectors -delete -type recoverypassword

The BitLocker Drive Encryption: Configuration Tool will now delete the protector. You may want to check this by running the first command again. Now you can add a new protector of type recovery password. That new protector will get a new id and a new password:

manage-bde.exe c: -protectors -add –rp

The configuration tool generates a new password, tells you to store it in a secure location and, if set up to do so, writes it to Active Directory.

Note: Every command used here, applies to the c: drive. You may want to change this according to your needs.

iPhone apps won’t open

In May I wrote a post about iPhone apps not opening after updating iOS to version 4.3.3. (iPhone apps won’t open after update to 4.3.3, complete post and comments). Now that Apple iOS versions 4.3.4 and 4.3.5 have been published this problem seems to still exist when updating from prior 4.3.3 to 4.3.3. or later.

Yesterday I updated my Apple iPhone to iOS 4.3.3 (no, it is not jailbreaked). After that I noticed that none of the installed apps run any more. Of course the built-in apps ran fine (like Maps, App Store, Calendar, Mail, Messages, Clock, Contacts, iTunes, Calculator, YouTube …). But none of the custom installed apps (I tried Facebook, WhatsApp, Amazon, eBay and at least every other app) – they just start, seem to run shortly (not even a second) and then the phone will return to the desktop, homescreen or whatever you call it.
Rebooting the phone didn’t fix the issue… But then, today, the problem was solved by simply installing all updates available in appstore. I don’t know if it was just enough logging in to appstore or if the updates where really necessary. Since there were only two updates available but dozens of apps that were not running, I think just logging in did the trick.

Opening a site in SharePoint Designer 2010 fails with unspecified error

When opening a site in Microsoft SharePoint Designer 2010 the following error occurs: “The server could not complete your request. For more specific information, click the Details button.” But when clicking the “Details” button, a window opens that does not specify anything. It says “Below is the message that the server returned. For more information, contact your Internet service provider or web server administrator.” But the message is empty. There are no details given on the error.

After closing both windows a message appears: “An error occurred while trying to fetch data from your SharePoint site. Unexpected response from the server. The content type of the response is “”. The status code is “OK”. All that you can do now is to hit OK. But the website will not be opened and nothing else will happen.

I don’t know why, but my first thought was about authentication. I checked it in the IIS Manager.

The authentication was set to “Windows Authentication”, its providers to “Negotiate:Kerberos” and “Negotiate”.

After adding NTLM to the list of providers I tried to open the website again in SharePoint Designer and it worked!

So if you change any authentication settings of your SharePoint sites always add NTLM as a fallback for the Designer. Otherwise it will not open websites authenticated by Windows Authentication.

How to configure item level recovery for Sharepoint 2010 with DPM 2010

I know that there are already a couple of articles covering this issue – but since I ran into trouble with exactly this configuration issue I realized that these articles do not cover everything. For example the problems you can run into.

To keep the steps to be taken as simple as possible I explain it regarding a Sharepoint farm with one server called “SHAREPOINT1″ and a DPM server called “DPM1″. The database server is sharepoint2010_test_db but we will not need this one while configuring backup.
Even in larger farms the steps to be taken will remain the same, because you will need to configure just one web frontend server.

First we need to deploy the Data Protection Manager 2010 agent. Just do it like you always did before:

  1. Open the DPM 2010 Administrator Console
  2. Switch to the management tab
  3. On the Agents panel hit “Install…”
  4. In the “Protection Agent Installation Wizard” choose “Install agents”
  5. Add your Sharepoint web frontend server
  6. Hit Next and enter you credentials
  7. Click Next and choose to not automatically restart the server
  8. On the last page click Install

When the installation is complete log on to your Sharepoint 2010 server and open an elevated command prompt. Now you need a domain account that has the farm administrator right and local administrator right on the server. I used the database access / farm administrator account used when deploying the farm: normanbauer.com\sp2010_test_fa. Of course you will also need its password!

Now type the following in the elevated command prompt (line by line; you may need to change the directory):

cd "%programfiles%\Microsoft Data Protection Manager\DPM\bin"
ConfigureSharepoint.exe -EnableSharePointProtection
ConfigureSharepoint.exe -EnableSPSearchProtection

For each of the ConfigureSharepoint commands you’ll need the account mentioned before. If the account you are using is not a member of the local administrators group on the server you will get an error message like this: “The specified Username and Password combination is Invalid.”

If everything worked correctly both commands will return “Operation completed successfully.” :

The account used for those two commands will be used as the run as credentials of a DPM developed DCOM object called WssCmdletWrapper:

Now you can configure the Sharepoint 2010 protection group in DPM. Again, go to the DPM 2010 Administrator Console and open the “Protection” panel. Create a new or modify an existing protection group. Add the server by choosing the database child item below the Sharepoint node of your server.

After completing the wizard DPM will start to synchronize all data. After that, you can review the progress in the Monitoring > Jobs panel, your databases can be restored using the Recovery panel. Simply navigate to your server > All Protected SharePoint Data > your database name. In the Recoverable Items list you can see your AdminContent DB, Config DB and any other Application databases you created before.

The problem now is, that you cannot navigate your application databases down to single items. DPM needs to create a catalog containing all urls of your Sharepoint sites first. This operation can take up to 24 hours but you can force DPM to do so immediately using PowerShell.

Open the DPM Management Shell from start menu and enter the following commands (please modify them to meet your servers names):

$dpmserver = "DPM1"
$sharepointserver = "SHAREPOINT1"
$pg = Get-ProtectionGroup $dpmserver
$ds = $pg | Get-Datasource
$sp = $ds | Where-Object {"$_.computer" -like "*" + $sharepointserver + "*" -and $_.type -like "*SharePoint*"}
$sp | Start-CreateCatalog

or as a one-liner:

Get-ProtectionGroup DPM1 | Get-Datasource | Where-Object {"$_.computer"; -like "*SHAREPOINT1*"; -and $_.type -like "*SharePoint*"} | Start-CreateCatalog

Now you should be able to navigate down to every single item of your farm:

If this is still not possible your account used to enable Sharepoint protection may not have sufficient rights. I had the problem when I first used a separate backup account that did not have a certain permission – I still do not know which one. I am currently using the farm administrator account, which is not a perfect solution but it works.

There is only one problem I found using that account: You cannot let Sharepoint change its password automatically from the managed accounts. Doing so would result in backup not working properly because the DCOM object mentioned before would need to be configured to use always the current password, which is not possible (as far as I know).

How to display user pictures in Outlook, Sharepoint & Co. using Active Directory?

Newer versions of Sharepoint, Outlook or Office Communicator support showing small user pictures in new mails, contact information or websites using data stored in a user’s object in Active Directory. Even Windows can show your user picture for example on the lock screen or in the start menu. But you need to make some preparations for this feature to work.
First at all you need the pictures for your user objects in the directory. You can use ADSI Edit, Powershell or 3rd party software to put pictures in AD. My blog post “How to save a user picture in Active Directory with vbScript?” will do this for you using vbScript.
The second step (only required if you have multiple domains) requires extend permissions on your forest. You’ll need at least the Schema Admin rights to edit the thumbnailPhoto attribute in the Active Directory Schema. View the attribute section in the Active Directory Schema snapin, open the properties of the thumbnailPhoto attribute and enable the option “Replicate this attribute to the Global Catalog”.
That’s all…
Note: This will work for Outlook, OCS, Sharepoint & Co. Windows will not use the data stored in the thumbnailPhoto attribute automatically. But there is a way to show the user picture in the start menu or on the lock screen. Please read my blog post “How to display Active Directory stored user account pictures in Windows?” for further information.