diff --git a/src/functions/TestDrive.ps1 b/src/functions/TestDrive.ps1 index 59cfd7146..e1374f33f 100644 --- a/src/functions/TestDrive.ps1 +++ b/src/functions/TestDrive.ps1 @@ -125,7 +125,8 @@ function Clear-TestDrive { function New-RandomTempDirectory { do { $tempPath = Get-TempDirectory - $Path = [IO.Path]::Combine($tempPath, ([Guid]::NewGuid())); + $dirName = 'Pester_' + [IO.Path]::GetRandomFileName().Substring(0, 4) + $Path = [IO.Path]::Combine($tempPath, $dirName) } until (-not [IO.Directory]::Exists($Path)) [IO.Directory]::CreateDirectory($Path).FullName diff --git a/src/functions/TestRegistry.ps1 b/src/functions/TestRegistry.ps1 index e821b8b4c..3208d1be3 100644 --- a/src/functions/TestRegistry.ps1 +++ b/src/functions/TestRegistry.ps1 @@ -73,7 +73,7 @@ function Get-TestRegistryChildItem ([string]$TestRegistryPath) { function New-RandomTempRegistry { do { $tempPath = Get-TempRegistry - $Path = & $SafeCommands['Join-Path'] -Path $tempPath -ChildPath ([Guid]::NewGuid()) + $Path = & $SafeCommands['Join-Path'] -Path $tempPath -ChildPath ([IO.Path]::GetRandomFileName().Substring(0, 4)) } until (-not (& $SafeCommands['Test-Path'] -Path $Path -PathType Container)) try {