Skip to content

Instantly share code, notes, and snippets.

@MauricioZa
Last active November 15, 2022 14:34
Show Gist options
  • Select an option

  • Save MauricioZa/166969a2a8b7204f83dbe71c6e0e3bae to your computer and use it in GitHub Desktop.

Select an option

Save MauricioZa/166969a2a8b7204f83dbe71c6e0e3bae to your computer and use it in GitHub Desktop.
# This script will create test local files in your on-premises file server.
# Later, you can use these files with robocopy to test the copy performance and network speed of your Azure Files setup.
# -----------------------------------------------------------------------
# Setup the directory where you want to create the dummy data
# -----------------------------------------------------------------------
##Dir creation
$Directory = "C:\dummy" ##Change as per requirement
New-Item -Path "$Directory\Large" -ItemType Directory
New-Item -Path "$Directory\Medium" -ItemType Directory
New-Item -Path "$Directory\Small" -ItemType Directory
# -----------------------------------------------------------------------
# Run the block below to create a set of small files
# -----------------------------------------------------------------------
#You can adjust the number of files and size to be created below:
$numberOfFiles = 10000
$bytes = 100KB
for ($i=1; $i -le $numberOfFiles; $i++)
{
[System.Security.Cryptography.RNGCryptoServiceProvider] $rng = New-Object System.Security.Cryptography.RNGCryptoServiceProvider
$rndbytes = New-Object byte[] $bytes
$rng.GetBytes($rndbytes)
[System.IO.File]::WriteAllBytes("$Directory\Small\Small_$i.txt", $rndbytes)
Write-Progress -Activity "Small file generation" -Status "Generatin file $i of $numberOfFiles" -PercentComplete ($i/$numberofFiles*100)
}
# -----------------------------------------------------------------------
# Run the block below to create a set of medium files
# -----------------------------------------------------------------------
#You can adjust the number of files and size to be created below:
$numberOfFiles = 1000
$bytes = 100MB
for ($i=1; $i -le $numberOfFiles; $i++)
{
[System.Security.Cryptography.RNGCryptoServiceProvider] $rng = New-Object System.Security.Cryptography.RNGCryptoServiceProvider
$rndbytes = New-Object byte[] $bytes
$rng.GetBytes($rndbytes)
[System.IO.File]::WriteAllBytes("$Directory\Medium\Medium_$i.txt", $rndbytes)
Write-Progress -Activity "Medium file generation" -Status "Generatin file $i of $numberOfFiles" -PercentComplete ($i/$numberofFiles*100)
}
# -----------------------------------------------------------------------
# Run the block below to create a set of large files
# -----------------------------------------------------------------------
#You can adjust the number of files and size to be created below:
$numberOfFiles = 100
$bytes = 1GB
for ($i=1; $i -le $numberOfFiles; $i++)
{
[System.Security.Cryptography.RNGCryptoServiceProvider] $rng = New-Object System.Security.Cryptography.RNGCryptoServiceProvider
$rndbytes = New-Object byte[] $bytes
$rng.GetBytes($rndbytes)
[System.IO.File]::WriteAllBytes("$Directory\Large\Large_$i.txt", $rndbytes)
Write-Progress -Activity "Large file generation" -Status "Generatin file $i of $numberOfFiles" -PercentComplete ($i/$numberofFiles*100)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment