-
Notifications
You must be signed in to change notification settings - Fork 0
/
Remove-statusFiles.ps1
79 lines (60 loc) · 2.26 KB
/
Remove-statusFiles.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
<#
.SYNOPSIS
This function removes all status files in the status file directory.
.DESCRIPTION
This function removes all status files in the status file directory.
.OUTPUTS
Empty status file directory.
.EXAMPLE
remove-statusFiles
#>
Function remove-statusFiles
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $false)]
[int]$functionThreadNumber=0,
[Parameter(Mandatory = $false)]
[boolean]$fullCleanup=$FALSE
)
[array]$threadStatus="ThreadZeroStatus.txt","ThreadOneStatus.txt","ThreadTwoStatus.txt","ThreadThreeStatus.txt","ThreadFourStatus.txt","ThreadFiveStatus.txt","ThreadSixStatus.txt","ThreadSevenStatus.txt","ThreadEightStatus.txt","ThreadNineStatus.txt","ThreadTenStatus.txt"
[string]$functionPath=$NULL
if ($fullCleanUp -eq $FALSE)
{
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN remove-StatusFile"
Out-LogFile -string "********************************************************************************"
$functionPath=Join-path $global:fullStatusPath $threadStatus[$functionThreadNumber]
out-logfile -string $functionPath
}
else
{
$functionPath=$global:fullStatusPath+"*"
}
try
{
if ($fullCleanup -eq $FALSE)
{
out-logfile -string "Removing files from the status directory."
}
remove-item -path $functionPath -force -errorAction STOP
}
catch
{
if ($fullCleanup -eq $FALSE)
{
out-logfile -string "Error removing log files." -isError:$TRUE
}
else
{
$_
}
}
if ($fullCleanup -eq $FALSE)
{
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "END remove-StatusFile"
Out-LogFile -string "********************************************************************************"
}
}