Get All Social Comments in SharePoint (For Admins, or Lazy Devs)

social-media-interaction-e1353080994137
Oh guess what, Social comments are known as Notes not comments, because well SharePoint.

I had a requirement to get a list of all the comments on a specific news story. (Publishing Story) I was looking for ways to accomplish this and I know that comments are stored not in the content database, but in the User Profile Social Database.  (At first I was like why in the world? And of course this will introduce other problems, but I can kinda see why now, so just roll with it. Although one of those problems could be, how can you retrieve user comments on a farm where you’re only restored the content database, but not the UPS databases? )

Anywho, I was trying to accomplish this with PowerShell, but wasn’t getting much traction. I saw there were some Social Comment controls out there, but I didn’t want to create a new page layout. There’s some methods to create this programmatically with CSOM, but being an admin who occasionally ventures into the developer world I was really struggling with how to get all those square shapes into those round puzzle holes. So I did something you should never do. I queried the database directly.  (I know I know, and I’m also not insane.) I had a copy of the database moved to a test farm and queried the database that way. 🙂 Haha, did you really think I’d go poking around in a live production SharePoint SQL database? Smh… I may have been born in the night, but it wasn’t last night. I figured out the tables that the comments were stored in and was able to extract a list then I noticed there was a userid associated with every comment as well as a URLID. I did some cross referencing of tables and ended up with a horrible horrible mess. Apparently the userid in one of the tables is actually not the same as an employee id etc…

So after delivering incorrect information and having it returned to me. I started looking at going back to the CSOM developer method, and I ran across this silly little article that mentioned there was an Out of the Box method to get all the comments for a news story from Central Administration. sigh… 2 days wasted…. But the CA method works.

To View the Social Comments through the CA.

  1. Open Central Administration.
  2. Click Manage Server Applications in the Application Management Section.
  3. Click the User Profile Service Application
  4. Click on Manager Social Tags and Notes.
    1. Oh guess what, Social comments are known as Notes not comments, because well SharePoint.
  5. By selecting Notes from the Type dropdown and by filling the values you could be able to see all the social comments based on your needs.

So here’s that article I found. (Thanks Vijai Anand Ramalingam!)  Hopefully it will save you some time if you get this same requirement. http://www.c-sharpcorner.com/uploadfile/anavijai/programmatically-get-all-the-social-comments-in-sharepoint-2010/

(43)

Get metadata column properties from all items in library. Can We Build It?!

canwebuildit sure if you have ever had to need to grab the metadata column values from a huge library in a SharePoint site.
Today I needed to grab specific column values from a library with over 50k rows in it. The great thing is with PowerShell you can absolutely do it. Getting the data was easy, but it took me a bit to toss the data into an array so that I could export it cleanly into a .csv file.  Originally I was just dumping it with Write-Out then piping that to Out-File command into a text file, but with Out-file it was putting each column’s value into a new line. (Apparently that’s default with Write-Out in PowerShell). So I had to bite the bullet and use the Export-CSV command. Of course I needed to move my For-Each into an array and that’s when things got fun for a while.
Anyways, got it working. As with all my scripts if you see a better way to make this go. Please leave me a comment!

Hopefully this helps and saves someone some time in the future.

[code language=”powershell”]

if((Get-PSSnapin | Where {$_.Name -eq “Microsoft.SharePoint.PowerShell”}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$Web = “https://spsiteurl”
$ListName = “Shared Documents”

$ExportFolder = “C:\ExportPath\”
$ExportName = Get-Date -f “dd-MM-yyyy-hh-mm-ss”
$ExportPath = $ExportFolder + $ListName + $ExportName + “.csv”

$sWeb = Get-SPWeb $Web
$sList = $sWeb.Lists[$ListName]
$sItems = $sList.GetItems()

$details = @() #I’m 80% sure you don’t need to declare this array
$results = @() #You MUST declare this array. (arrays love arrays homie)

# These will be the names of the columns you want to get from the list.
$sItems | ForEach-Object {
$_[‘ID’], $_[‘Title’], $_[‘Modified By’], $_[‘Created’], $_[‘Project’], $_[‘Status’]

# I created alias variables below because I ran
# into some items that didn’t convert into or from strings. You may not need this.
$DocID = $_[‘ID’]
$DocTitle = $_[‘Title’]
$DocModifiedBy = $_[‘Modified By’]
$DocCreatedBy = $_[‘Created’]
$DocProject = $_[‘Project’]
$DocStatus = $_[‘Status’]

#Build an array called details
$details = @{
DocumentID = $DocID
DocumentTitle = $DocTitle
ModifiedBy = $DocModifiedBy
CreatedBy = $DocCreatedBy
DocumentProject = $DocProject
DocumentStatus = $DocStatus
}

$results += New-Object PSObject -Property $details
}

$results | Export-Csv $ExportPath -NoTypeInformation
$sWeb.Dispose()

[/code]

Happy SharePointing.

(36)

Fun with Facebook Scammers

 

So today, I was waiting in line for our company Christmas lunch, and I got a friend request on Facebook. I knew the person, and accepted, and immediately got a message from them in my inbox.

They said, “How are you doing”, and I told them I was going, and then I suddenly remembered, that I was already friends with this person. I checked my friends list and sure enough 2 accounts from the same person with the exact same picture. At that point i pretty much knew it was a scam, and this was a fake account. Of course since I had about a 30 minute wait in line before we could be seated, I figured I’d go ahead and play their game for a while. 🙂

They asked me if I’d heard about the great news about Facebook giving away money to users. I of course acted surprised.

Next they told me how they had actually been selected and gotten 90,000.00 dollars delivered by UPS to their doorstep and they managed to look at the list, and saw my name was on it too, and asked if I’d already been contacted by a Facebook Agent yet.

I told them how much I really needed that money and no, no one from Facebook had contacted me, but I really really needed that money!!!!

So they told me that I need to friend the agent and let them know that I am wanting to claim my money.
They then sent me a link to a Facebook account to friend.
Not wanting to rush into it too fast, I tried to make some small talk about how I’d spend the money, and I asked if I could even send the money to their house so my kids wouldn’t see UPS delivery cash to my door. The user told me no and that I should immediately contact the “Agent”. I tried to ask a few more questions, but they were all ignored and told to contact the Agent.
So since I still had about 15 more minutes to wait, I went ahead and friend requested “the Agent”.
I immediately got a Message from “The Agent”. I’ve copied my exchange from “The Agent” below. I wasn’t able to capture the content from the first conversation with the fake friend account because FB already killed that account, so all the replies from that fake account show up as “This message has been temporarily removed because the sender’s account requires verification.”

Anyways, I had some fun while waiting. and thought I’d share.

The key thing here is be mindful, scammers are out there. Ultimately this person wanted me to send them some contact information, not too personal, and then they told me I’d have to pay $200 for them to ship the money to me. I didn’t get to play with them long enough to stretch that part out, but anyways, enjoy.
You and Thomas Dorothy aren’t connected on Facebook
ONLINE CLAIMING AGENT !!! at Facebook
Lives in Texas City, Texas
  • Conversation started today
  • Thomas Dorothy
    11:16am

    Thomas Dorothy

    HELLO….HOW ARE YOU DOING AND ARE YOU HERE TO CLAIM YOUR PACKAGE??

  • Marrell Sanders
    11:18am

    Marrell Sanders

    Yes but i need to send it to Mary, but she wont let me

  • Thomas Dorothy
    11:18am

    Thomas Dorothy

    WHATS YOUR FULL NAME TO CHECK ON THE DATA BASE IF YOUR NAME STILL ON THE WINNERS LIST?

  • Marrell Sanders
    11:19am

    Marrell Sanders

    Hang on im gonna call mary and ask her

    Sure mary said i was on the list

  • Thomas Dorothy
    11:19am

    Thomas Dorothy

    Claims Requirements: To claim you will need to fill this form,so that we can Locate Your Destination when bringing the Money to you are you ready to fill the form now?

  • Marrell Sanders
    11:19am

    Marrell Sanders

    Marrell Sanders

    Yes

    Yes but im going to ask Mary

  • Thomas Dorothy
    11:20am

    Thomas Dorothy

    Name……………………… Address……………………. City…………………….. State……………………. Zip code…………………. E-mail Address……….. Text phone…………….. Occupation…………….. Male or female………… Age…………………………

  • Thomas Dorothy
    11:20am

    Thomas Dorothy

    YOU JUST HAVE TO ANSWER THAT BACK TO US IN HERE ONE AFTER THE OTHER

  • Marrell Sanders
    11:21am

    Marrell Sanders

    Why do you need my occupation?

  • Thomas Dorothy
    11:21am

    Thomas Dorothy

    you need to fill the form back here

    just did as we say

  • Marrell Sanders
    11:21am

    Marrell Sanders

    Whats that? Which form?

  • Thomas Dorothy
    11:22am

    Thomas Dorothy

    Name……………………… Address……………………. City…………………….. State……………………. Zip code…………………. E-mail Address……….. Text phone…………….. Occupation…………….. Male or female………… Age…………………………

  • Marrell Sanders
    11:24am

    Marrell Sanders

    Can i use fake information?

    I don’t know if i should put it all on.

    I can message mary anymore. Do you know mary?

  • Thomas Dorothy
    11:25am

    Thomas Dorothy

    were you aware you paying $200 for the shipping fee?

  • Marrell Sanders
    11:25am

    Marrell Sanders

    No, but thats okay i can do that. If i can goto marys

  • Thomas Dorothy
    11:26am

    Thomas Dorothy

    ok so you can fill the form now

  • Marrell Sanders
    11:27am

    Marrell Sanders

    Sure but i dont see a form, just some lines is it a pdf? What is the link?

  • Thomas Dorothy
    11:27am

    Thomas Dorothy

    Name………………………

    Answer that back to us

  • Marrell Sanders
    11:28am

    Marrell Sanders

    I can’t wait. To get the momey will. Ie be here before Christmas? So i can buy my kids presenta5

    My name is Marrell

  • Thomas Dorothy
    11:28am

    Thomas Dorothy

    Address…………………….

  • Marrell Sanders
    11:29am

    Marrell Sanders

    What arw you getting for.christmas?

    I live in oklahoma city

    Do you need my house numbet?

    Are you going to email me the form?

  • Thomas Dorothy
    11:30am

    Thomas Dorothy

    State…………………….

  • Marrell Sanders
    11:31am

    Marrell Sanders

    I live in oklahoma

    But seriously what are you getting for Christmas?

  • Thomas Dorothy
    11:32am

    Thomas Dorothy

    Zip code………………….

  • Marrell Sanders
    11:33am

    Marrell Sanders

    73102

    Im hoping to get an xbox. I really want to play Halo 5. Have you heard of it?

  • Thomas Dorothy
    11:34am

    Thomas Dorothy

    E-mail Address………..

  • Marrell Sanders
    11:34am

    Marrell Sanders

    Hmm i still cant message Mary

    Do you know.why?

    Techrevmarrell@facebook.com

  • Thomas Dorothy
    11:35am

    Thomas Dorothy

    Text phone……………..

  • Marrell Sanders
    11:35am

    Marrell Sanders

    How long does it take to get money btw?

    Thats pretty important

  • Thomas Dorothy
    11:36am

    Thomas Dorothy

    Text phone……………..

  • Marrell Sanders
    11:36am

    Marrell Sanders

    How long to.arrive?

  • Thomas Dorothy
    11:37am

    Thomas Dorothy

    Male or female…………

  • Marrell Sanders
    11:37am
  • Thomas Dorothy
    11:37am
  • Marrell Sanders
    11:38am

    Marrell Sanders

    I live with 4 girls and i have a girl cat. But can i skip.that question? Id rather not say

  • Thomas Dorothy
    11:38am

    Thomas Dorothy

    Age…………………………

  • Marrell Sanders
    11:38am
  • Thomas Dorothy
    11:38am

    Thomas Dorothy

    Age…………………………

  • Marrell Sanders
    11:39am

    Marrell Sanders

    Im over 18, but not 50 yet

    Seriously how long.doea it take to get the money?

 Unfortunately the scammer must have gotten frustrated with me, and blocked me from messaging them, as I only get this message now.
blockedFB

(26)

Merge-SPLogFile made “slightly” easier (PowerShell script)

powershell_2Download script Here: mergesplogfile

If you’re a SharePoint Administrator something you probably learned pretty early in your adventure is if there’s an error or problem. CHECK YOUR LOGS! APP LOGS, SYS LOGS, EVENT LOGS, ULS Logs, etc… There’s a saying that “LOGS DON’T LIE!” And I believe that to be accurate 99% of the time. Albeit of those logs are often as clear as mud…. Perhaps interviewers should be looking for people who have the skillset “fluent in reading logs” on their resume.

Anyways, with SharePoint the best log source would be those produced by the Unified Logging Service, or ULS. Those are by default those logs are stored at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\(Hive)Logs But any admin worth their weight in donuts will immediately find another drive to write these logs to as they can, and will do their best to eat up every available bit of drive space you have available, particularly when you use the VERBOSE setting. If there’s a SharePoint issue, most likely you’ll find the culprit and root cause in the ULS log.

If you have a multi farm environment, then each one of those servers gets it’s own set of ULS logs. This is great because if your search server is angry and logging a ton of search related stuff in it’s ULS folder, your Web Front End Server doesn’t have to suffer with all those search writes. This is also horrible, because now you have to look at multiple locations to figure out where that correlation ID wrote itself to, or to get ALL the Logs from ALL the servers about a particular issue. Maybe you have 1 misbehaving WFE, now it’s guess which one is acting up. All in all it just slows you down. Well in SharePoint 2010 Microsoft introduced a PowerShell cmdlet that merges the logfile from all of the Servers into 1 single file and exports it to a location. This was a HUGE HUGE plus to admins everywhere!  If you want more information about the Merge-SPLogfile command go here. https://technet.microsoft.com/en-us/library/ff607721.aspx

Now I use Merge-SPLogfile daily, sometimes multiple times per hour, and when I’m really trying to track down an issue, I may run it back to back to back to …. well you get the idea.

What I dislike is having to type out the command: merge-splogfile -correlation “RandomGuidGoesHere” -path “Ihopethisfolderpathhereiscorrect”  every single time that run the command, so I wrote a really simple script to make things a tad bit faster. It prompts you for which operation you’d like to use. The filename you want it to save as, adds a timestamp to that name, in case you need 10 files named “StupidServer.txt”

Hopefully someone can find it useful. Right now it only includes the operations to merge based on a correlation ID and a StartTime and EndTime. Should be really easy to update this to support additional operations.

Anyways here ya go. Just save this as a .ps1 file, update the $LogFileFolder variable and give it a run. Pretty self explanatory.
Download script Here: mergesplogfile

Hope it’s helpful and Happy SharePointing

(55)

404 errors, http, https and other fun things with SharePoint SPSiteURL

If you’re using host named site collections in SharePoint 2013 and have set an SPSiteURL in order to map a site collection to a different zone, you may have noticed when you backup that site from one farm to another farm, the default zone moves correctly to the destination farm, but any other zones continue to contain the url from the original source farm. Usually this presents it self as the site working when using the Default zone, but getting a pretty 404, when using the alternate zones. (Users love to use alternate zones). 🙂

lego404

(Best 404 eva!)

Let say you moved a site collection called https://myweb.contoso.com/sites/teamA and needed to move it to a staging farm, so you restored it at https://myweb.stg.contoso.com/sites/teamA
The default zone url is https while the intranet zone is http.

Powershell: (run Get-SPSiteURL against the Top Level Site Collection (Root Site) using the Default zone URL)
Get-SPSiteURL -Identity https://myweb.contoso.com
E.g.
Source Farm Top Level Site Collection
Url Zone
https://myweb.contoso.com Default
http://myweb.contoso.com Intranet
Destination Farm Top Level Site Collection
Url Zone
https://myweb.stg.contoso.com Default
http://myweb.stg.contoso.com Intranet
All the site collections get the Default and Intranet Zones from the Top Level Site Collection.
Now if you run Get-SPSiteURL against the actual site collection you just restored
E.g. Get-SPSiteURL -identity https://myweb.stg.contoso.com/sites/teamA
You’ll see the following.
Url Zone
https://myweb.stg.contoso.com/sites/teamA Default
http://myweb.contoso.com/sites/teamA Intranet
Notice the Intranet Zone in invalid. If you’re on the source farm, you can’t hit the site http://myweb.contoso.com/sites/teamA because that URL is technically not registered to anything in that farm. I’m not sure if they correct term is orphaned, but that’s the term I’ll use. (because reasons)
If a user were to try and access http://myweb.stg.contoso/sites/teamA it was also fail to find that site. even though http:// for any of the other site collections would work just fine.
So how do we fix this issue?
First thought would be to simply remove the invalid Zone from the newly restored site collection by running.
But you’ll get an error because 1. This url is really not mapped anywhere in this farm. (Orphaned) and because 2. you can’t directly modify a zone of a site collection except by modifying the Top Level site collection zone and it cascading down to all the other site collections zones in that host name.
So unfortunately, we need to get the invalid URL added to our top level site collection zone. This means we need to remove our current top level site collection zone for Intranet. *(Note: this will cause this zone to stop working on all the site collection under this host name group, not just the top level)
remove-SPSiteURL -url http://myweb.stg.contoso.com
This removes the URL above from your Intranet Zone (or really in any zone that is may have been mapped to)
Well for some silly reason, we first have to add this invalid URL to our Top Level Site collection before we can remove it again
So run this command to set the invalid URL into the -Zone
set-spsiteurl -identity https://myweb.stg.contoso.com -url http://myweb.contoso.com -zone intranet
if you perform
get-SPSiteURL -identity https://myweb.stg.contoso.com
you will now see that the Top Level Zones looks like this
Url Zone
https://myweb.stg.contoso.com Default
http://myweb.contoso.com/sites Intranet
Run
Get-SPSiteURL – identity https://myweb.stg.contoso.com/sites/teamA
And you will also see
Url Zone
https://myweb.stg.contoso.com/sites/teamA Default
http://myweb.contoso.com/sites/teamA Intranet
Now we can remove this invalid URL from the Top Level Intranet Zone.
remove-SPSiteURL -url http://myweb.contoso.com
then add the correct URL
set-spsiteurl -identity https://myweb.stg.contoso.com -url http://myweb.stg.contoso.com -zone intranet
And now this zone will cascade through the site collection underneath that hostname included the previously restored site collection.
Now perform
and you should see this:
Url Zone
https://myweb.stg.contoso.com/sites/teamA Default
http://myweb.stg.contoso.com/sites/teamA Intranet
 This entire process seemed confusing and probably more steps than were needed, but it seems to do the trick. As always if you have a better method, shoot me a line, lemme know!
Happy SharePointing!
#SPAdminLife

(92)

SharePoint 2010 Mainstream support ending October 13th, 2015

 

 

 

I’m sure most of you have already heard, or were already aware (months ago), that SharePoint 2010 Mainstream support is ending soon.
Stefan posted it on his technet blog yesterday and here’s a link in case you missed it. http://blogs.technet.com/b/stefan_gossner/archive/2015/07/16/still-on-sharepoint-2010.aspx

Many of us who were running critical apps on SharePoint 2007, (or heaven’s no, SharePoint 2003) already know what this means.
But in case you don’t, here is a chart taken from the Microsoft Support Lifecycle page that explains the differences between the type of support available in these phases as well as other questions you may have. https://support.microsoft.com/en-us/lifecycle?p1=14944#gp/lifePolicy

And no, this doesn’t mean your SharePoint 2010 farms are going to burst into balls of virtual flames on Oct 14th, 2015. (Although if that does happen to you, DM me a picture!)

microsoftsupport Graph

(34)

« Previous Entries