forked from proxb/PoshWSUS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-PSWSUSEmailConfig.ps1
61 lines (52 loc) · 1.6 KB
/
Get-PSWSUSEmailConfig.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function Get-PSWSUSEmailConfig {
<#
.SYNOPSIS
Retrieves the email notification configuration from WSUS.
.DESCRIPTION
Retrieves the email notification configuration from WSUS.
.PARAMETER SendTestEmail
Optional switch that will send a test email to the configured email addresses
.NOTES
Name: Get-PSWSUSEmailConfig
Author: Boe Prox
DateCreated: 24SEPT2010
.LINK
https://learn-powershell.net
.EXAMPLE
Get-PSWSUSEmailConfig
Description
-----------
This command will display the configuration of the email notifications.
.EXAMPLE
Get-PSWSUSEmailConfig -SendTestEmail
Description
-----------
This command will send a test email to the address or addresses in the To field.
#>
[cmdletbinding()]
Param(
[Parameter(
Position = 0,
ValueFromPipeline = $False)]
[switch]$SendTestEmail
)
Begin {
if($wsus)
{
$email = $wsus.GetEmailNotificationConfiguration()
}#endif
else
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
If ($PSBoundParameters['SendTestEmail']) {
$email.SendTestEmail()
Write-Output"Test email sent."
} Else {
$email
}
}
}