When I’m trying to set the MySiteHostUrl via PowerShell it throws an error. Taking a closer look it seems after initializing the UserProfileManager class an UserProfileApplicationNotAvailableException is raised.
The exception you receive is
New-Object : Exception calling ".ctor" with "1" argument(s): "UserProfileApplicationNotAvailableException_Logging :: UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have 458839b6-4979-413a-a7a3-41d8564faea3"
The PowerShell script I’m using is retrieving the current context and initializing the UserProfileManager object. This should provide me access to the MySiteHostUrl.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0 $site = Get-SPSite “http://my.contoso.com” $context = Get-SPServiceContext($site) $upm = New-Object -TypeName Microsoft.Office.Server.UserProfiles.UserProfileManager -ArgumentList $context $upm.MySiteHostURL = “http://my.contoso.com”
The solution to this is providing the account running the PowerShell script sharing permissions “Full Control” on the User Profile Service Application.
- Open Central Administration
- Click Service Applications
- Select “User Profile Service Application”
- Click in ribbon the Permissions button
- Add account which is running PS script, in this example “xxx-spinstall”
- Select “Full Control” and click OK
- Run the PS-script again!