-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSaveTraceFile.ps1
More file actions
27 lines (18 loc) · 774 Bytes
/
SaveTraceFile.ps1
File metadata and controls
27 lines (18 loc) · 774 Bytes
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
$SaveFileDir = "D:\ArchivedTraceFiles"
$7zipPath = "C:\Program Files\7-Zip\7z.exe"
$SaveFileDate = (Get-Date).AddDays(-1)
$DirYear = "{0:yyyy}" -f $SaveFileDate
$DirMonth = "{0:MM}" -f $SaveFileDate
$SaveFileName = "{0:yyyy-MM-dd}" -f $SaveFileDate
try{
If( -Not (Test-Path "$SaveFileDir\$DirYear")) {
New-Item -Path "$SaveFileDir" -name "$DirYear" -type Directory
}
If( -Not (Test-Path "$SaveFileDir\$DirYear\$DirMonth")) {
New-Item -Path "$SaveFileDir\$DirYear" -name "$DirMonth" -type Directory
}
If( -Not (Test-Path "$SaveFileDir\$DirYear\$DirMonth\$SaveFileName.zip")) {
&$7zipPath a -tzip "$SaveFileDir\$DirYear\$DirMonth\$SaveFileName.zip" "$SaveFileDir\$SaveFileName\*"
Remove-Item -Recurse -Force "$SaveFileDir\$SaveFileName"
}
} catch {}