-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFillD.ps1
125 lines (115 loc) · 4.85 KB
/
FillD.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<#
Disk Test/Free Space Wipe
Place in the folder where you want to make the files
#>
<# Variables #>
$dynamicFreeSpace = $True #Ignore freeSpaceHaltSize and determine a reasonable freespace size (half free space unless it's over 10GB, then it's fixed at 10GB)
#freeSpaceHaltSize ignored if dynamicFreeSpace is True
$freeSpaceHaltSize = '741,374,182,400' #examples 1,099,511,627,776 1TB, 107,374,182,400 100GB, 10,737,418,240 10GB, 1,073,741,824 1GB, 104,857,600 100MB,
$baseFileName = 'DEADBEEF' #file will contain 64kb of "DE AD BE EF" hex
$DevID = "DeviceID='C:'"
$PadFilePath = "C:\!FITPadFiles-doNotDelete"
#Debugging
#$DebugPreference = "Continue"
#Logging feature
#$ErrorActionPreference="SilentlyContinue"
try { Stop-Transcript | out-null } catch { }
#start a transcript file
try { Start-Transcript -path $scriptLog } catch { }
#current script directory
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
#current script name
$path = Get-Location
$scriptName = $MyInvocation.MyCommand.Name
$scriptLog = "$scriptPath\log\$scriptName.log"
$filename = (Join-Path $PadFilePath $baseFileName)
$guid =[System.GUID]::NewGuid().ToString().ToUpper()
$newFileName = (Join-path $PadFilePath ($guid + '-' + $baseFileName))
Write-Host Current GUID: $guid
Write-Host Starting...
#Create destination path if it doesn't exist
If (!(Test-Path -Path $PadFilePath)) { New-Item -Path $PadFilePath -ItemType Directory -Force }
<# Begin Program #>
$ByteArrayPattern = new-object byte[](1024kb)
[byte[]]$ByteArrayPattern = for ($i=1; $i -le 1024kb; $i++){
if ($i % 4 -eq 0) { 0xDE }
elseif ($i % 4 -eq 1) { 0xAD }
elseif ($i % 4 -eq 2) { 0xBE }
elseif ($i % 4 -eq 3) { 0xEF }
}
Write-Host Starting Disk Object...
$disk = Get-WmiObject Win32_LogicalDisk -Filter $DevID | Select-Object FreeSpace
if ($dynamicFreeSpace) {
Write-Host Current freespace in bytes: $disk.FreeSpace
$fillsize = ($disk.FreeSpace / 2)
If ($fillsize -gt 10737418240) {
$fillsize = 10737418240
}
Write-Host Leaving this many bytes free: ($disk.FreeSpace / 2)
Write-Host Filling this many bytes: $fillsize
}
else {
$freeSpaceHaltSize = $freeSpaceHaltSize -replace ',', ''
Write-Host Current freespace in bytes: $disk.FreeSpace
Write-Host Leaving this many bytes free: $freeSpaceHaltSize
$fillsize = ($disk.FreeSpace - $freeSpaceHaltSize)
Write-Host Filling this many bytes: $fillsize
}
$Level1 = [int]($fillsize / 1048576 / 10)
$Level2 = [int]($Level1 / 10)
$Level3 = [int]($Level2 / 10)
$Level4 = [int]($Level3 / 10)
Write-Host Number of 1mb loops at each level L1 $Level1, L2 $Level2, L3 $Level3, L4 $Level4
for ($a=1; $a -le 9; $a++) {
Write-Host Freespace $disk.FreeSpace
$guid =[System.GUID]::NewGuid().ToString().ToUpper()
$newFileName = (Join-path $PadFilePath ($guid + '-' + $baseFileName))
write-host $newFileName
set-content -value $ByteArrayPattern -encoding byte -path $filename
for ($i=1; $i -le $Level1; $i++) {
add-content -value $ByteArrayPattern -encoding byte -path $filename
Write-Host((Get-Item $filename).length/1MB)
}
Rename-Item -Path $filename -NewName ($newFileName + $a)
$disk = Get-WmiObject Win32_LogicalDisk -Filter $DevID | Select-Object FreeSpace
}
for ($a=1; $a -le 9; $a++) {
Write-Host Freespace $disk.FreeSpace
$guid =[System.GUID]::NewGuid().ToString().ToUpper()
$newFileName = (Join-path $PadFilePath ($guid + '-' + $baseFileName))
write-host $newFileName
set-content -value $ByteArrayPattern -encoding byte -path $filename
for ($i=1; $i -le $Level2; $i++) {
add-content -value $ByteArrayPattern -encoding byte -path $filename
Write-Host((Get-Item $filename).length/1MB)
}
Rename-Item -Path $filename -NewName ($newFileName + $a)
$disk = Get-WmiObject Win32_LogicalDisk -Filter $DevID | Select-Object FreeSpace
}
for ($a=1; $a -le 9; $a++) {
Write-Host Freespace $disk.FreeSpace
$guid =[System.GUID]::NewGuid().ToString().ToUpper()
$newFileName = (Join-path $PadFilePath ($guid + '-' + $baseFileName))
write-host $newFileName
set-content -value $ByteArrayPattern -encoding byte -path $filename
for ($i=1; $i -le $Level3; $i++) {
add-content -value $ByteArrayPattern -encoding byte -path $filename
Write-Host((Get-Item $filename).length/1MB)
}
Rename-Item -Path $filename -NewName ($newFileName + $a)
$disk = Get-WmiObject Win32_LogicalDisk -Filter $DevID | Select-Object FreeSpace
}
for ($a=1; $a -le 9; $a++) {
Write-Host Freespace $disk.FreeSpace
$guid =[System.GUID]::NewGuid().ToString().ToUpper()
$newFileName = (Join-path $PadFilePath ($guid + '-' + $baseFileName))
write-host $newFileName
set-content -value $ByteArrayPattern -encoding byte -path $filename
for ($i=1; $i -le $Level4; $i++) {
add-content -value $ByteArrayPattern -encoding byte -path $filename
Write-Host((Get-Item $filename).length/1MB)
}
Rename-Item -Path $filename -NewName $newFileName
$disk = Get-WmiObject Win32_LogicalDisk -Filter $DevID | Select-Object FreeSpace
}
Write-Host Done