-
Notifications
You must be signed in to change notification settings - Fork 10
/
Get-MigrationSummary.ps1
102 lines (76 loc) · 3.44 KB
/
Get-MigrationSummary.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
101
102
<#
.SYNOPSIS
This function scans the folders and outputs a migration summary.
.DESCRIPTION
This function scans the folders and outputs a migration summary.
.PARAMETER logFolderPath
This is the log folder path that contains the files for auditing.
.OUTPUTS
No return.
.EXAMPLE
get-MigrationSummary -logFolderPath $logFolderPath
#>
Function get-MigrationSummary
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
$logFolderPath
)
#Output all parameters bound or unbound and their associated values.
write-functionParameters -keyArray $MyInvocation.MyCommand.Parameters.Keys -parameterArray $PSBoundParameters -variableArray (Get-Variable -Scope Local -ErrorAction Ignore)
[array]$failedJobs = @()
[array]$successJobs = @()
$workingDirectories = $NULL
#Start function processing.
Out-LogFile -string '********************************************************************************'
Out-LogFile -string 'BEGIN GET-MIGRATIONSUMMARY'
Out-LogFile -string '********************************************************************************'
$workingDirectories = get-childItem -path $logFolderPath -recurse -directory
foreach ($directory in $workingDirectories)
{
out-logfile -string ('Evaluating Directory: '+$directory.name)
if ($directory.name -like '*FAILED')
{
out-logfile -string ('Failed Detected: '+$directory.name)
$failedJobs+=$directory
}
elseif ($directory.name -like '*SUCCESS*')
{
out-logfile -string ('Success Detected: '+$directory.name)
$successJobs+=$directory
}
else
{
out-logfile -string 'Directory neither success or fail.'
}
}
out-logfile -string '================================================================================'
out-logfile -string '***MIGRATION SUMMARY***'
out-logfile -string '================================================================================'
out-logfile -string ''
out-logfile -string '+++FAILED SUMMARY+++'
out-logfile -string ('Number of failed migrations: ' + $failedJobs.count)
foreach ($job in $failedJobs)
{
$temp = $job.name.split('-')
$tempStatus = $temp[-1]
$tempGroupName = $temp[1..($temp.count - 2)] -join '-'
out-logfile -string "Group: $($tempGroupName) Status: $($tempStatus)"
}
out-logfile -string ''
out-logfile -string '+++SUCCESS SUMMARY+++'
out-logfile -string ('Number of successful migrations: ' + $successJobs.count)
foreach ($job in $successJobs)
{
$temp = $job.name.split('-')
$tempStatus = $temp[-1]
$tempGroupName = $temp[1..($temp.count - 2)] -join '-'
out-logfile -string "Group: $($tempGroupName) Status: $($tempStatus)"
}
out-logfile -string '================================================================================'
out-logfile -string '================================================================================'
Out-LogFile -string 'END GET-MIGRATIONSUMMARY'
Out-LogFile -string '********************************************************************************'
}