if (
$PSVersionTable
) {
$Host
.Runspace.ThreadOptions =
'ReuseThread'
}
Add-PSSnapin
Microsoft.SharePoint.PowerShell
-ErrorAction
SilentlyContinue
# get the health reports list
$ReportsList
= [Microsoft.SharePoint.Administration.Health.SPHealthReportsList]::Local
$FormUrl
=
'{0}{1}?id='
-f
$ReportsList
.ParentWeb.Url,
$ReportsList
.Forms.List.DefaultDisplayFormUrl
$body
=
$ReportsList
.Items |
Where-Object
{$_[
'Severity'
]
-ne
'4 - Success'
} |
ForEach-Object
{
New-Object
PSObject
-Property
@{
Url =
"$($_['Title'])"
Severity = $_[
'Severity'
]
Category = $_[
'Category'
]
Explanation = $_[
'Explanation'
]
Modified = $_[
'Modified'
]
FailingServers = $_[
'Failing Servers'
]
FailingServices = $_[
'Failing Services'
]
Remedy = $_[
'Remedy'
]
}
} |
ConvertTo-Html
|
Out-String
# creating clickable HTML links
$body
=
$body
-replace
'<'
,
'<'
-replace
'>'
,
'>'
-replace
'"'
,
'"'
$params
= @{
To =
'you@domain.com'
,
'manager@domain.com'
From =
'SPHealth@domain.com'
Subject =
'Daily Health Analyzer report'
SmtpServer =
'smtp1'
Body =
$body
BodyAsHtml =
$true
}
Send
-MailMessage
@params
Source: Shay Levy
Ingen kommentarer:
Send en kommentar