So consider the following scenario:
Users log in to their MySites and are able to see their Profile and Newsfeed. However, whenever they click on their Tasks link, they get redirected back to their Newsfeed. It's almost as though SharePoint is treating them as a stranger to their own MySite.
We spun several hours on this problem, and I'm not sure our scenario fits for everyone.
The cause of our problem was we had migrated many thousands of MySites from one farm to a new farm. We did this as part of a large scale farm upgrade. When we did that, we did not backup and restore the User Profile databases.
Both farms were in the same domain, same usernames in Active Directory. However, the rub came in the mismatch between the User Profile databases and the MySite content databases.
When a User Profile is imported from Active Directory, SharePoint assigns a GUID to that Profile and stores it in the User Profile database. It then assigns that GUID to the MySite (in the MySites Property Bag) when the user first creates their MySite.
In our case, since the MySites were attached already, the creation action never fired. And since the Profile GUID in the MySite Property Bag was different than the GUID in the Profile Database, when the user tried to click on their Tasks list, SharePoint didn't recognize them.
But there's a fix. You can do this on a multiple site basis, or on an individual MySite basis. The Powershell is:
$Web = Get-SPWeb http://[MySiteURL]/personal/[UserID]
$Web.SetProperty("urn:schemas-microsoft-com:sharepoint:portal:profile:userprofile_guid",
"[NewGUID]")
$Web.Update()
You can get the NewGUID by querying UserProfileManager in PowerShell or by going to User
Profile Service Application -> Manage User Profiles -> Find the user
profile that is having issues -> Edit User Profile
Then get the GUID out of the URL ProfAdminEdit.aspx?guid=[NewGUID]
The credit for this one goes to Matt Coleman and Matt Royer - two of the guys on our team that dug pretty deep on this problem. Hopefully it helps someone else out there.
Day to day Powershell, SharePoint, and Project Server experiences. Any scripts here are provided as-is, and you're encouraged to test them before you run them on production. Most are scripts I've altered to suit my needs, and come from places like Stack Overflow or TechNet.
Wednesday, May 25, 2016
Thursday, May 12, 2016
Take ownership of SharePoint files with no checked in version, check them in, and publish with Powershell
This script will take ownership of all files in a library, then set whatever required metadata needs to be set, then check the items in.
Handy if a user has uploaded a ton of data using Explorer View, but never updated the metadata, and never actually checked in the files.
if ((Get-PSSnapin | ? { $_.Name -eq "Microsoft.SharePoint.PowerShell" }) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
function BrowseItems($list, $Locationterm, $Departmentterm) {
$files = $list.CheckedOutFiles
foreach($file in $files)
{
$file.TakeOverCheckOut() #Take ownership of checked out document
}
foreach ($item in $list.Items) {
$itemFile = $item.File
if ($itemFile -ne $null) {
if ($itemFile.CheckOutStatus -ne "None") {
$LocationtaxField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$item.Fields["GAC Location"]
$DepartmenttaxField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$item.Fields["GAC Department"]
$fileName = $itemFile.Name
$userName = $itemFile.CheckedOutByUser.Name;
$item["Title"] = $fileName
$LocationtaxField.SetFieldValue($item,$Locationterm)
$DepartmenttaxField.SetFieldValue($item,$Departmentterm)
$item.update()
#Write-Host "Doing automatic CheckIn on the item" -f green -NoNewline
$itemFile.CheckIn("Automatic CheckIn (Administrator)")
#Write-Host " Done!" -f Yellow
if( $list.EnableVersioning -and $list.EnableMinorVersions) {
#Write-Host "Doing automatic Publish on the item" -f green -NoNewline
$itemFile.Publish("Automatic Publish (Administrator)")
Write-Host "." -f Yellow
}
}
}
}
}
$url = "http://somesite.com/sites/teamsite/subweb"
$web = Get-SPWeb $url
$site = $web.Site
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Taxonomy")
$session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
$termStore = $session.TermStores[0]
$Locationgroup = $termStore.Groups["Locations"]
$LocationtermSet = $Locationgroup.TermSets["Location"]
$Locationterms = $LocationtermSet.GetAllTerms()
$Locationterm = $Locationterms | ?{$_.Name -eq "SomeCity"}
$Departmentgroup = $termStore.Groups["Departments"]
$DepartmenttermSet = $Departmentgroup.TermSets["Department"]
$Departmentterms = $DepartmenttermSet.GetAllTerms()
$Departmentterm = $Departmentterms | ?{$_.Name -eq "SomeDepartment"}
$list = $web.lists["Some Document Library"]
BrowseItems $list $Locationterm $Departmentterm
Thursday, May 5, 2016
Rename a List or Library in SharePoint 2013 with Powershell
Don't save the List or Library as a template, then restore it. Use Powershell instead!
add-pssnapin microsoft.sharepoint.powershell
$libOriginalUrl = "/Lists/OldListURL/";
$libNewUrl = "/Lists/NewListURL";
$web = Get-SPWeb -Identity http://somesite.com/sites/teamsite
$lib = $web.GetList($web.Url + $libOriginalUrl)
$rootFolder = $lib.RootFolder;
$rootFolder.MoveTo($web.Url + $libNewUrl)
add-pssnapin microsoft.sharepoint.powershell
$libOriginalUrl = "/Lists/OldListURL/";
$libNewUrl = "/Lists/NewListURL";
$web = Get-SPWeb -Identity http://somesite.com/sites/teamsite
$lib = $web.GetList($web.Url + $libOriginalUrl)
$rootFolder = $lib.RootFolder;
$rootFolder.MoveTo($web.Url + $libNewUrl)
Subscribe to:
Posts (Atom)