Skip to content

Instantly share code, notes, and snippets.

@p0shkatz
Last active April 18, 2019 03:14
Show Gist options
  • Save p0shkatz/f1b170acd0e9dcab6616dfe5861a8c32 to your computer and use it in GitHub Desktop.
Save p0shkatz/f1b170acd0e9dcab6616dfe5861a8c32 to your computer and use it in GitHub Desktop.
powershell disk filler
# File to create/update
$filePath = "$($env:userprofile)\Desktop\large-test-file.txt"
$hFile = [System.IO.File]::OpenWrite($filePath)
# Lynch pin file to stop process
$lpFilePath = "$($env:userprofile)\Desktop\lynch.pin"
$hLpFile = [System.IO.File]::OpenWrite($lpFilePath)
$hLpFile.Close()
# Target System drive
$driveInfo = New-Object System.IO.DriveInfo($env:SystemDrive)
while([System.IO.File]::Exists($lpFilePath))
{
$hFile.SetLength($hFile.Length + $driveInfo.AvailableFreeSpace)
}
# Cleanup
$hFile.Close()
[System.IO.File]::Delete($filePath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment