Skip to content

Commit

Permalink
Remove invalid characters in basename sourced from username (#1190)
Browse files Browse the repository at this point in the history
Fixes #1189

This fixes a bug where a username may contain spaces or other invalid characters, e.g.
```
(py39_new) PS C:\github.com\azure-sdk-for-python> .\eng\common\TestResources\New-TestResources.ps1 'schemaregistry'
New-TestResources.ps1: The variable cannot be validated because the value Sean Kaneschemaregistry is not a valid value for the BaseName variable.
```
  • Loading branch information
benbp authored Nov 11, 2020
1 parent b9c55de commit 4985971
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ if (!$templateFiles) {
}

$UserName = if ($env:USER) { $env:USER } else { "${env:USERNAME}" }
# Remove spaces, etc. that may be in $UserName
$UserName = $UserName -replace '\W'

# If no base name is specified use current user name
if (!$BaseName) {
Expand Down

0 comments on commit 4985971

Please sign in to comment.