-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMoveRequestReport.ps1
More file actions
239 lines (195 loc) · 12 KB
/
MoveRequestReport.ps1
File metadata and controls
239 lines (195 loc) · 12 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
[CmdletBinding()]
param (
[bool]$CompletedMoves = $false,
[bool]$Synced = $false,
[bool]$Inprogress = $false,
[bool]$AllMoves = $true,
[bool]$IncludeAllBadItems = $true,
[bool]$MoveDataBasic = $true,
[bool]$MoveDataFull = $true,
[bool]$GenereExportInfo = $true
)
#region Functions
function generateBadItemInformation ($BadItem,$User)
{
$ExportEntry = New-Object PSObject
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Identity -Value $User.Alias
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BatchName -Value $User.Batchname
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name DisplayName -Value $User.DisplayName
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Date -Value $BadItem.Date
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Subject -Value $BadItem.Subject
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Kind -Value $BadItem.Kind
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name FolderName -Value $BadItem.FolderName
$ExportEntry
}
function generateBasicMoveInformation ($User)
{
$ExportEntry = New-Object PSObject
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Identity -Value $User.Alias
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BatchName -Value $User.Batchname
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name DisplayName -Value $User.DisplayName
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Status -Value $User.Status
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name SyncStage -Value $User.SyncStage
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RemoteDatabase -Value $User.RemoteDatabase
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RemoteHostName -Value $User.RemoteHostName
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Message -Value $User.Message
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RecipientTypeDetails -Value $User.RecipientTypeDetails
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalMailboxSize -Value $User.TotalMailboxSize
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalMailboxItemCount -Value $User.TotalMailboxItemCount
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalArchiveSize -Value $User.TotalArchiveSize
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalArchiveItemCount -Value $User.TotalArchiveItemCount
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalPrimarySize -Value $User.TotalPrimarySize
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalPrimaryItemCount -Value $User.TotalPrimaryItemCount
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BytesTransferred -Value $User.BytesTransferred
$ExportEntry
}
function generateFullMoveInformation ($User)
{
$ExportEntry = New-Object PSObject
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Identity -Value $User.Alias
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BatchName -Value $User.Batchname
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name DisplayName -Value $User.DisplayName
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Status -Value $User.Status
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name SyncStage -Value $User.SyncStage
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RemoteDatabase -Value $User.RemoteDatabase
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RemoteHostName -Value $User.RemoteHostName
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Message -Value $User.Message
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RecipientTypeDetails -Value $User.RecipientTypeDetails
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalMailboxSize -Value $User.TotalMailboxSize
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalMailboxItemCount -Value $User.TotalMailboxItemCount
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalArchiveSize -Value $User.TotalArchiveSize
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalArchiveItemCount -Value $User.TotalArchiveItemCount
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalPrimarySize -Value $User.TotalPrimarySize
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalPrimaryItemCount -Value $User.TotalPrimaryItemCount
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BytesTransferred -Value $User.BytesTransferred
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name OverallDuration -Value $User.OverallDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalSuspendedDuration -Value $User.TotalSuspendedDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalFailedDuration -Value $User.TotalFailedDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalQueuedDuration -Value $User.TotalQueuedDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalInProgressDuration -Value $User.TotalInProgressDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name StatusDetail -Value $User.StatusDetail
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name SourceVersion -Value $User.SourceVersion
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name FailureCode -Value $User.FailureCode
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name FailureType -Value $User.FailureType
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name FailureSide -Value $User.FailureSide
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name QueuedTimestamp -Value $User.QueuedTimestamp
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name StartTimestamp -Value $User.StartTimestamp
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name LastUpdateTimestamp -Value $User.LastUpdateTimestamp
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name LastSuccessfulSyncTimestamp -Value $User.LastSuccessfulSyncTimestamp
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name InitialSeedingCompletedTimestamp -Value $User.InitialSeedingCompletedTimestamp
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToContentIndexingDuration -Value $User.TotalStalledDueToContentIndexingDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToMdbReplicationDuration -Value $User.TotalStalledDueToMdbReplicationDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToMailboxLockedDuration -Value $User.TotalStalledDueToMailboxLockedDuration
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToReadThrottle -Value $User.TotalStalledDueToReadThrottle
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToWriteThrottle -Value $User.TotalStalledDueToWriteThrottle
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToReadCpu -Value $User.TotalStalledDueToReadCpu
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToWriteCpu -Value $User.TotalStalledDueToWriteCpu
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToReadUnknown -Value $User.TotalStalledDueToReadUnknown
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalStalledDueToWriteUnknown -Value $User.TotalStalledDueToWriteUnknown
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalTransientFailureDuration -Value $User.TotalTransientFailureDuration
$ExportEntry
}
function GenerateExcelInformation ($BadItems,$User)
{
$ExportEntry = New-Object PSObject
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Identity -Value $User.Alias
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BatchName -Value $User.Batchname
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name DisplayName -Value $User.DisplayName
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Status -Value $User.Status
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name SyncStage -Value $User.SyncStage
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RemoteDatabase -Value $User.RemoteDatabase
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RemoteHostName -Value $User.RemoteHostName
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name Message -Value $User.Message
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name RecipientTypeDetails -Value $User.RecipientTypeDetails
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalMailboxSize -Value $User.TotalMailboxSize
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name TotalMailboxItemCount -Value $User.TotalMailboxItemCount
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BadItems -Value $BadItems.Count
$ExportEntry | Add-Member -MemberType "NoteProperty" -Name BytesTransferred -Value $User.BytesTransferred
$ExportEntry
}
#endregion
#region Global Vales
$LogPath = "C:\Scripts\"
$FileTimeStamp = (Get-Date -Format yyyyMMdd-HHmmss).ToString()
$ExportBadItems = @()
$ExportBasicInformation = @()
$ExportFullInformation = @()
$ExportExcelInfo = @()
$Moves = @()
#endregion
#region Collect Movedata
If($AllMoves){
$Moves = Get-MoveRequest | Get-MoveRequestStatistics -IncludeReport
}
If($CompletedMoves){
$Moves = Get-MoveRequest -MoveStatus Completed | Get-MoveRequestStatistics
}
If($Synced){
$Moves += Get-MoveRequest -MoveStatus Synced | Get-MoveRequestStatistics
}
If($Inprogress){
$Moves += Get-MoveRequest -MoveStatus Inprogress | Get-MoveRequestStatistics
}
#endregion
#region Process moves Data
If($IncludeAllBadItems){
$Moves2 = get-migrationuser | where{$_.SkippedItemCount -gt 0} | Get-MoveRequestStatistics -IncludeReport
Foreach ($Move in $Moves2){
$Baditems = ""
$Baditems = ($Move.Report).Baditems
If($Baditems -eq ""){
Write-Host "No Errors found for " -BackgroundColor Green
}
Else{
Foreach($BadItem in $Baditems){
$ExportBadItems += generateBadItemInformation -BadItem $Baditem -User $Move
}
}
}
}
If($GenereExportInfo){
Foreach ($Move in $Moves){
$Baditems = ""
$Baditems = ($Move.Report).Baditems
If($Baditems -eq ""){
Write-Host "No Errors found for " -BackgroundColor Green
}
Else{
$ExportExcelInfo += GenerateExcelInformation -BadItems $Baditems -User $Move
}
}
}
If($MoveDataBasic){
Foreach ($Move in $Moves){
$ExportBasicInformation += generateBasicMoveInformation -User $Move
}
}
If($MoveDataFull){
Foreach ($Move in $Moves){
$ExportFullInformation += generateFullMoveInformation -User $Move
}
}
#endregion
#region Export data
If($IncludeAllBadItems){
$ExportBadItems | ogv
$FileName = $LogPath+"BadItems"+$FileTimeStamp+".csv"
$ExportBadItems | Export-Csv -Path $FileName -NoTypeInformation
}
If($MoveDataBasic){
$ExportBasicInformation | ogv
$FileName = $LogPath+"BasicMoveData"+$FileTimeStamp+".csv"
$ExportBasicInformation |Export-Csv -Path $FileName -NoTypeInformation
}
If($MoveDataFull){
$ExportFullInformation | ogv
$FileName = $LogPath+"FullMoveData"+$FileTimeStamp+".csv"
$ExportFullInformation | Export-Csv -Path $FileName -NoTypeInformation
}
if($ExportExcelInfo){
$ExportExcelInfo | ogv
$FileName = $LogPath+"ExcelData"+$FileTimeStamp+".csv"
$ExportExcelInfo | Export-Csv -Path $FileName -NoTypeInformation
}
#endregion
#-Delimiter ";"