Send Email Message using Powershell

We use this script to send email notifications from within another powershell script.  This is useful if you are running scripts thru scheduled tasks and you want to be notified of failure (or success):


# Name:  SendEmail.ps1

# To invoke this script from another powershell script:
# & ".\SendEmail.ps1"  -Subject 'Email' -SendFrom 'FromAddress' -SendTo 'ToAddress' -Body $emailbody

param($Subject="Unknown",$SendFrom="FromAddress",$SendTo="ToAddress",$Body="No Body")

$SMTPServer = "SMTPServerName"
$from = $SendFrom
$to = $SendTo
$subject = $Subject
$emailBody = $Body
$mailer = New-Object Net.Mail.SMTPclient($SMTPServer)
$msg = New-Object Net.Mail.MailMessage($from, $to, $subject, $emailBody)

$mailer.send($msg)

Visual Upgrade all Webs in Site Collection with Powershell

While upgrading to SharePoint 2010, if you have chosen not to upgrade to the new user experience at upgrade time, you can upgrade all webs in a site collection after-the-fact with the following script:

Add-PSSnapin Microsoft.SharePoint.PowerShell

$site = Get-SPSite(”http://SiteCollectionURL“)
foreach ($web in $site.AllWebs) { $web.UIVersion = 4; $web.Update() }

Add Synonym Thesaurus Entries to SharePoint Search

Trying to get the user community to “buy-in” to the search capabilities of SharePoint?  The use of thesaurus files
in SharePoint can help with the search experience.

Problem: Jobtitle is a user profile property synced up to Active Directory and it contains a
pre-defined formal list of values.  (Eg.  Vice President, Executive Vice President, Regional Vice President, etc.)
When a SharePoint end-user is in People Search and types in ‘VP’ as a search term, they expect the returned results will include results for ‘Vice President’, ‘Executive Vice President’, ‘Regional Vice President’ and ‘VP’. Continue reading “Add Synonym Thesaurus Entries to SharePoint Search”

Viewing Search Results XML

If you need to view the actual xml that is returned in SharePoint search results, you need to modify the search core results webpart and replace the display properties with this:

<?xml version=”1.0″ encoding=”UTF-8″?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“>
<xsl:output method=”xml” version=”1.0″ encoding=”UTF-8″ indent=”yes”/>
<xsl:template match=”/”>
<xmp><xsl:copy-of select=”*”/></xmp>
</xsl:template>
</xsl:stylesheet>

Note:  Remember to backup the old display properties for the search core results webpart in case it was customized before doing this.

Here is the MSDN Link for a more in-depth explanation of this.