PowerShell 技能连载 - Creating Dummy Test Files

If you need to test file system load, test failover clusters, or need large dummy files otherwise, rather than creating new files and slowly filling them with random data, try this:

$filepath = "$env:temp\testfile.txt"
$sizeBytes = 5.75MB

$file = [System.IO.File]::Create($filepath)
$file.SetLength($sizeBytes)
$file.Close()
$file.Dispose()

# show dummy file in Windows Explorer
explorer /select,$filepath

This code creates dummy files of any size in a snap and can be used to quickly create storage load. Just don’t forget to delete these files after use.

PowerShell 技能连载 - Creating Dummy Test Files

http://blog.vichamp.com/2021/09/10/creating-dummy-test-files/

作者

吴波

发布于

2021-09-10

更新于

2022-07-06

许可协议

评论