-
Notifications
You must be signed in to change notification settings - Fork 4
/
Update-ALs (2).ps1
100 lines (80 loc) · 2.37 KB
/
Update-ALs (2).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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# **********************************************************************************
#
# Script Name: Update-ALs.ps1
# Version: 1.0
# Author: Davde M
# Date Created: 10/16/2012
# _______________________________________
#
# MODIFICATIONS:
# Date Modified: N/A
# Modified By: N/A
# Reason for modification: N/A
# What was modified: N/A
#
# Description: Updates all GALs and ALs.
#
# Usage:
# ./Update-ALs.ps1
#
# **********************************************************************************
<#
.SYNOPSIS
Updates all ALs and GALs
.DESCRIPTION
Gets all Address Lists and Global Address Lists and forces the system to update them.
.EXAMPLE
./Script_Name_Here.ps1
Description
===========
Updates all ALs and GALs
.NOTES
Requires Janus and Exchange Module Loaded.
#>
# Functions and Filters
# Main Script
# The Begin section executes once regardless of how many objects are passed through the pipeline
begin
{
$error.clear()
if ($global:JanusPSModule -ne $true) {Import-Module Janus -erroraction stop}
Show-JStatus
if ($global:E2010SnapIn -ne $true)
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
$global:E2010SnapIn=$?
$global:ExchangeSnapIn=$global:E2010SnapIn
}
# Initialization
$syslogobject=New-JSyslogger -dest_host "p-ucslog02.janus.cap"
[string]$LOG=""
[string]$Report="Address List Update Report:`n"
}
# The process section runs once for each object in the pipeline
process
{
$LOG="Get-AddressList `| Update-AddressList"
Get-AddressList | Update-AddressList
$success=$?
$LOG=$LOG + " - Successful: $success"
$syslogobject.send($log)
$report=$report + "`n" + $log + "`n"
$LOG="Get-GlobalAddressList `| Update-GlobalAddressList"
Get-GlobalAddressList | Update-GlobalAddressList
$success=$?
$LOG=$LOG + " - Successful: $success"
$syslogobject.send($log)
$report=$report + "`n" + $log + "`n"
}
# The End section executes once regardless of how many objects are passed through the pipeline
end
{
$log=$error | out-string
$syslogobject.send($log)
$report=$report + "`n`nError Log:`n" + $log + "`n"
Send-MailMessage -SmtpServer mailman.janus.cap -From "[email protected]" -To "[email protected]" -Subject "Address List Update Report" -Body $report
remove-variable success
remove-variable report
remove-variable log
remove-variable syslogobject
}