Wednesday, August 3, 2016

Create Test SSL Certificate for IIS With PowerShell and Windows 2012 R2

In order to create an SSL Certificate for test purpose you can bind to a web site in IIS, you do not need anymore certutil or makecert.

Windows 2012 R2 PowerShell has a commandlet you can use for this purpose.

This simple command, for example, create a SSL Cert using 2048 key lenght and valid for 5 years.

New-SelfSignedCertificate -KeyLength 2048 -NotAfter (Get-Date).AddYears(5) -certstorelocation "cert:\localmachine\my" -dnsname youfqdnwebappname

This cert will be stored in "localmachine\my" and can be used in IIS binding.

You can find more info and parameters here:

https://technet.microsoft.com/en-US/library/hh848633.aspx

Pay attention that the same command on Windows 2012 (not R2 version) do not have the same parameters. For example you cannot use -NotAfter parameter. This means that you certificate will have a validity of only one year (that one is the default).

Thursday, January 21, 2016

Fix List Incoming Email Settings after SharePoint Migration

During a SharePoint Migration from 2010 to 2013 of a customer, we have seen that incoming email no longer worked as expected.
So I tried to reset via UI incoming email settings for a specific List and we saw that the service is come back to work.
The following PowerShell script do the same thing I've done through SharePoint UI but works across all lists of a specific web application.
Every properties of incoming email setting of a list are stored into Propertie Bag of the RootFolder of the list.
These settings are preserved even if we disable incoming email alias setting it to $null.

$SPWebApp = Get-SPWebApplication "http://webappurl"

foreach ($SPsite in $SPwebApp.Sites)
{
   foreach($SPweb in $SPsite.AllWebs)
  {
     foreach ($SPList in $SPweb.Lists)
     {
         if ( ($splist.CanReceiveEmail) -and ($SPlist.EmailAlias) )
         {
             #save email alias
             $emailAlias = $SPList.EmailAlias
             #disable incoming email
             $SPList.EmailAlias = $null
             $splist.Update()
             #re-enable incoming email
             $SPList.EmailAlias = $emailAlias
             $splist.Update()
         }
     }
  }
}


These are all the properties for incoming email settings at List level you can set/check:

  • vti_emailsaveoriginal
  • vti_emailattachmentfolders
  • vti_emailusesecurity
  • vti_emailoverwrite
  • vti_emailsavemeetings