Thursday, April 24, 2014

SPBG knowledge sharing session about JavaScript security

The Danish user SPBG organizing knowledge-sharing session about JavaScript Safety Committee on 22 May from 17 pm to about 19 ​​times. You can read more about the meeting here http://spbg.dk/Lists/Mder/DispForm.aspx?ID=69

Tuesday, April 22, 2014

Find a process in a SharePoint farm

Last week I had to help a SharePoint 2010 customer to fix a bug in production environment, containing of three servers. When I looked through the log files, with my favorite ULS logging view tool http://archive.msdn.microsoft.com/ULSViewer, I could see that they was an error about a dll file, which was missing. “System.IO.FileNotFoundException: Could not load file or assembly 'XX.Sharepoint2010, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XX' or one of its dependencies”. However, the error was only showing in some request. So step one, was to figure out which server the dll was missing found, but the ULS log view do not show any thing in the server column.

GetComputerNameByProcessId

Nevertheless, looking in the Process column, we can find the hex value for the process that encounter the error. Then by looping throw all the servers in the farm, with the role type of application, we can call a get-process

Like this:

1 function Get-ComputerNameByProcessId ($processId)
2 {
3 [int]$processIdAsInt = [Convert]::ToInt32($processId)
4 $servers = Get-SPServer | ? { $_.Role -eq "Application" } | % {
5 Get-Process -computername $_.Address -Id $processIdAsInt -ErrorAction:SilentlyContinue | select MachineName
6 }
7 }
8 Get-ComputerNameByProcessId 0x1358
9