Thursday, 14 April 2016

Comparing MD5 hashes with PowerShell

I do very much appreciate when software publishers publish the MD5 hashes of their binaries or image files. This way I can verify that a file has not changed as a result of a faulty file transfer, a disk error or other manipulation.
PowerShell has a (not very well known) cmdlet for creating MD5 hashes - Get-FileHash.
However, this was still to manual for me. Compute the file hash, read the hash from the .md5 file and manually compare the hashes.
Therefore I wrote myself a small PowerShell script that required two parameters - the path to the binary or image file and the path to the .md5 file. It assumes that the hash is the first 32 characters in the .md5 file.

An example how to run the script would be:

PS C:\Users\admin\Downloads> .\Check-Md5Sum -param1 .\windows81.iso -param2 .\windows81.md5

Wednesday, 13 April 2016

Finding duplicate alerts in SharePoint

SharePoint alerts are email notifications sent out by SharePoint in case anything changes in a Document Library or any kind of List (e.g. Task Lists, Announcements, Calendars, etc.).
There are plenty of good reasons to setup alerts - you edit the work on the same set of documents with different people and want to get notified if some document is changed, you want to get notifications on new events in a calendar, or you want to monitor changes in a Document Library.

Now alerts are something very much user-related. You can easily setup alerts for other team members of groups via the SharePoint webpages, but to track who has set which alert for himself is not possible.
Recently I was asked: “Why I always get this alarm twice?”. PowerShell to the rescue.

We have available the following information:
  • Username ($_.User)
  • Site Collection URL ("")
  • URL of the Subsite ($_.ParentWebUrl)
  • Name of the List / Library ($_.Title)

The bellow code snippet works for hostnamed site collections and will check for a specific library in a specific subsite.

$SPsite = Get-SPSite ""
$SPweb = $SPsite.AllWebs
$ListID = $SPweb.Lists | select Title, ID, ParentWebUrl | where { $_.Title -like "*Workshops*" -AND $_.ParentWebUrl -like "*digitalmarketing*" }
$SPweb.Alerts | select Title, User, ListID | where { $_.ListID -eq $ListID.ID.Guid -AND $_.User -like "*CONTOSO\william.faulkner*" }