diff --git a/avm/res/compute/virtual-machine/tests/unit/avm.core.team.tests.ps1 b/avm/res/compute/virtual-machine/tests/unit/avm.core.team.tests.ps1 index 15532c48ed..a6229b35e4 100644 --- a/avm/res/compute/virtual-machine/tests/unit/avm.core.team.tests.ps1 +++ b/avm/res/compute/virtual-machine/tests/unit/avm.core.team.tests.ps1 @@ -17,7 +17,7 @@ BeforeAll { . (Join-Path $RepoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'helper' 'Get-IsParameterRequired.ps1') if ($moduleFolderPaths.Count -gt 1) { - $topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object | Select-Object -First 1 + $topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object -Culture 'en-US' | Select-Object -First 1 } else { $topLevelModuleTemplatePath = $moduleFolderPaths } diff --git a/avm/res/network/nat-gateway/tests/unit/avm.core.team.tests.ps1 b/avm/res/network/nat-gateway/tests/unit/avm.core.team.tests.ps1 index ee6d4dc083..eb8c8928b0 100644 --- a/avm/res/network/nat-gateway/tests/unit/avm.core.team.tests.ps1 +++ b/avm/res/network/nat-gateway/tests/unit/avm.core.team.tests.ps1 @@ -17,7 +17,7 @@ BeforeAll { . (Join-Path $RepoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'helper' 'Get-IsParameterRequired.ps1') if ($moduleFolderPaths.Count -gt 1) { - $topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object | Select-Object -First 1 + $topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object -Culture 'en-US' | Select-Object -First 1 } else { $topLevelModuleTemplatePath = $moduleFolderPaths } diff --git a/avm/utilities/pipelines/e2eValidation/resourceRemoval/Initialize-DeploymentRemoval.ps1 b/avm/utilities/pipelines/e2eValidation/resourceRemoval/Initialize-DeploymentRemoval.ps1 index 2ceed9e64b..d5d4c20503 100644 --- a/avm/utilities/pipelines/e2eValidation/resourceRemoval/Initialize-DeploymentRemoval.ps1 +++ b/avm/utilities/pipelines/e2eValidation/resourceRemoval/Initialize-DeploymentRemoval.ps1 @@ -134,11 +134,11 @@ function Initialize-DeploymentRemoval { if ($PurgeTestResources) { # Resources $filteredResourceIds = (Get-AzResource).ResourceId | Where-Object { $_ -like '*dep-*' } - $ResourceIds += ($filteredResourceIds | Sort-Object -Unique) + $ResourceIds += ($filteredResourceIds | Sort-Object -Culture 'en-US' -Unique) # Resource groups $filteredResourceGroupIds = (Get-AzResourceGroup).ResourceId | Where-Object { $_ -like '*dep-*' } - $ResourceIds += ($filteredResourceGroupIds | Sort-Object -Unique) + $ResourceIds += ($filteredResourceGroupIds | Sort-Object -Culture 'en-US' -Unique) } # Invoke removal diff --git a/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Get-ResourceIdsAsFormattedObjectList.ps1 b/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Get-ResourceIdsAsFormattedObjectList.ps1 index 69f83360eb..731b62ee33 100644 --- a/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Get-ResourceIdsAsFormattedObjectList.ps1 +++ b/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Get-ResourceIdsAsFormattedObjectList.ps1 @@ -78,7 +78,7 @@ function Get-ResourceIdsAsFormattedObjectList { $allResourceGroupResources = Get-AzResource -ResourceGroupName $resourceGroupName -Name '*' } $expandedResources = $allResourceGroupResources | Where-Object { $_.ResourceId.startswith($resourceId) } - $expandedResources = $expandedResources | Sort-Object -Descending -Property { $_.ResourceId.Split('/').Count } + $expandedResources = $expandedResources | Sort-Object -Culture 'en-US' -Descending -Property { $_.ResourceId.Split('/').Count } foreach ($resource in $expandedResources) { $formattedResources += @{ resourceId = $resource.ResourceId diff --git a/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Remove-Deployment.ps1 b/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Remove-Deployment.ps1 index fdea2ed239..00a0d50676 100644 --- a/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Remove-Deployment.ps1 +++ b/avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Remove-Deployment.ps1 @@ -116,7 +116,7 @@ function Remove-Deployment { # Pre-Filter & order items # ======================== - $rawTargetResourceIdsToRemove = $deployedTargetResources | Sort-Object -Property { $_.Split('/').Count } -Descending | Select-Object -Unique + $rawTargetResourceIdsToRemove = $deployedTargetResources | Sort-Object -Culture 'en-US' -Property { $_.Split('/').Count } -Descending | Select-Object -Unique Write-Verbose ('Total number of deployment target resources after pre-filtering (duplicates) & ordering items [{0}]' -f $rawTargetResourceIdsToRemove.Count) -Verbose # Format items diff --git a/avm/utilities/pipelines/platform/Invoke-AvmJsonModuleIndexGeneration.ps1 b/avm/utilities/pipelines/platform/Invoke-AvmJsonModuleIndexGeneration.ps1 index 2704177b8e..b48b67f864 100644 --- a/avm/utilities/pipelines/platform/Invoke-AvmJsonModuleIndexGeneration.ps1 +++ b/avm/utilities/pipelines/platform/Invoke-AvmJsonModuleIndexGeneration.ps1 @@ -98,7 +98,7 @@ function Invoke-AvmJsonModuleIndexGeneration { Write-Error "Error message: $($_.Exception.Message)" continue } - $tags = $tagListResponse.tags | Sort-Object + $tags = $tagListResponse.tags | Sort-Object -Culture 'en-US' $properties = [ordered]@{} foreach ($tag in $tags) { @@ -190,7 +190,7 @@ function Invoke-AvmJsonModuleIndexGeneration { } else { # If the module exists, merge the tags and properties $mergedModule = $initialMergeOfJsonFilesData[$module.moduleName] - $mergedModule.tags = @(($mergedModule.tags + $module.tags) | Sort-Object -Unique) + $mergedModule.tags = @(($mergedModule.tags + $module.tags) | Sort-Object -Culture 'en-US' -Unique) # Merge properties foreach ($property in $module.properties.PSObject.Properties) { @@ -205,7 +205,7 @@ function Invoke-AvmJsonModuleIndexGeneration { $mergedModuleIndexData = $initialMergeOfJsonFilesData.Values # Sort the modules by their names - $sortedMergedModuleIndexData = $mergedModuleIndexData | Sort-Object moduleName + $sortedMergedModuleIndexData = $mergedModuleIndexData | Sort-Object -Culture 'en-US' -Property 'moduleName' Write-Verbose "Convert mergedModuleIndexData variable to JSON and save as 'moduleIndex.json'" -Verbose $sortedMergedModuleIndexData | ConvertTo-Json -Depth 10 | Out-File -FilePath $moduleIndexJsonFilePath diff --git a/avm/utilities/pipelines/publish/helper/Get-ModulesToPublish.ps1 b/avm/utilities/pipelines/publish/helper/Get-ModulesToPublish.ps1 index 0ba3ef62cf..e7f2ca0471 100644 --- a/avm/utilities/pipelines/publish/helper/Get-ModulesToPublish.ps1 +++ b/avm/utilities/pipelines/publish/helper/Get-ModulesToPublish.ps1 @@ -102,7 +102,7 @@ function Get-TemplateFileToPublish { $TemplateFilesToPublish = $relevantPaths | ForEach-Object { Find-TemplateFile -Path $_ -Verbose - } | Sort-Object -Unique -Descending + } | Sort-Object -Culture 'en-US' -Unique -Descending if ($TemplateFilesToPublish.Count -eq 0) { Write-Verbose 'No template file found in the modified module.' -Verbose diff --git a/avm/utilities/pipelines/sharedScripts/Add-YamlListToFile.ps1 b/avm/utilities/pipelines/sharedScripts/Add-YamlListToFile.ps1 index b81cec6cad..4a7732c651 100644 --- a/avm/utilities/pipelines/sharedScripts/Add-YamlListToFile.ps1 +++ b/avm/utilities/pipelines/sharedScripts/Add-YamlListToFile.ps1 @@ -69,7 +69,7 @@ function Add-YamlListToFile { throw "No key-value pairs found in List: $ListName" } # Process key value pairs in the list - foreach ($Key in ($KeyValuePair.Keys.split(' ') | Sort-Object)) { + foreach ($Key in ($KeyValuePair.Keys.split(' ') | Sort-Object -Culture 'en-US')) { Write-Verbose ('Setting environment variable [{0}] with value [{1}]' -f $Key, $KeyValuePair[$Key]) -Verbose Write-Output "$Key=$($KeyValuePair[$Key])" | Out-File -FilePath $OutputFilePath -Encoding 'utf-8' -Append } diff --git a/avm/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 b/avm/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 index 12de5cec07..bcfb7253ab 100644 --- a/avm/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 +++ b/avm/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 @@ -63,7 +63,7 @@ function Install-CustomModule { $alreadyInstalled = $alreadyInstalled | Where-Object { $_.Version -eq $Module.Version } } else { # Get latest in case of multiple - $alreadyInstalled = ($alreadyInstalled | Sort-Object -Property Version -Descending)[0] + $alreadyInstalled = ($alreadyInstalled | Sort-Object -Culture 'en-US' -Property 'Version' -Descending)[0] } Write-Verbose ('Module [{0}] already installed with version [{1}]' -f $alreadyInstalled.Name, $alreadyInstalled.Version) -Verbose continue diff --git a/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 b/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 index 43ee7b2dd7..83c923f601 100644 --- a/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 +++ b/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 @@ -95,7 +95,7 @@ function Set-ResourceTypesSection { $RelevantResourceTypeObjects = Get-NestedResourceList $TemplateFileContent | Where-Object { $_.type -notin $ResourceTypesToExclude -and $_ - } | Select-Object 'Type', 'ApiVersion' -Unique | Sort-Object Type -Culture 'en-US' + } | Select-Object 'Type', 'ApiVersion' -Unique | Sort-Object -Culture 'en-US' -Property 'Type' $ProgressPreference = 'SilentlyContinue' $VerbosePreference = 'SilentlyContinue' @@ -277,9 +277,9 @@ function Set-DefinitionSection { # Filter to relevant items if (-not $Properties) { # Top-level invocation - [array] $categoryParameters = $TemplateFileContent.parameters.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Property 'Name' -Culture 'en-US' + [array] $categoryParameters = $TemplateFileContent.parameters.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Culture 'en-US' -Property 'Name' } else { - $categoryParameters = $Properties.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Property 'Name' -Culture 'en-US' + $categoryParameters = $Properties.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Culture 'en-US' -Property 'Name' } $tableSectionContent += @( @@ -657,13 +657,13 @@ function Set-CrossReferencesSection { $dependencies = $CrossReferencedModuleList[$FullModuleIdentifier] if ($dependencies.Keys -contains 'localPathReferences' -and $dependencies['localPathReferences']) { - foreach ($reference in ($dependencies['localPathReferences'] | Sort-Object)) { + foreach ($reference in ($dependencies['localPathReferences'] | Sort-Object -Culture 'en-US')) { $SectionContent += ("| ``{0}`` | {1} |" -f $reference, 'Local reference') } } if ($dependencies.Keys -contains 'remoteReferences' -and $dependencies['remoteReferences']) { - foreach ($reference in ($dependencies['remoteReferences'] | Sort-Object)) { + foreach ($reference in ($dependencies['remoteReferences'] | Sort-Object -Culture 'en-US')) { $SectionContent += ("| ``{0}`` | {1} |" -f $reference, 'Remote reference') } } @@ -1283,11 +1283,11 @@ function Set-UsageExamplesSection { $moduleNameCamelCase = $First.Tolower() + (Get-Culture).TextInfo.ToTitleCase($Rest) -Replace '-' } - $testFilePaths = (Get-ChildItem -Path $ModuleRoot -Recurse -Filter 'main.test.bicep').FullName | Sort-Object + $testFilePaths = (Get-ChildItem -Path $ModuleRoot -Recurse -Filter 'main.test.bicep').FullName | Sort-Object -Culture 'en-US' $RequiredParametersList = $TemplateFileContent.parameters.Keys | Where-Object { Get-IsParameterRequired -TemplateFileContent $TemplateFileContent -Parameter $TemplateFileContent.parameters[$_] - } | Sort-Object + } | Sort-Object -Culture 'en-US' ############################ ## Process test files ## diff --git a/avm/utilities/pipelines/sharedScripts/helper/ConvertTo-OrderedHashtable.ps1 b/avm/utilities/pipelines/sharedScripts/helper/ConvertTo-OrderedHashtable.ps1 index cfd446753e..f270726499 100644 --- a/avm/utilities/pipelines/sharedScripts/helper/ConvertTo-OrderedHashtable.ps1 +++ b/avm/utilities/pipelines/sharedScripts/helper/ConvertTo-OrderedHashtable.ps1 @@ -63,7 +63,7 @@ function ConvertTo-OrderedHashtable { return $JSONObject # E.g. in primitive data types [1,2,3] } - foreach ($currentLevelKey in ($JSONObject.Keys | Sort-Object)) { + foreach ($currentLevelKey in ($JSONObject.Keys | Sort-Object -Culture 'en-US')) { if ($null -eq $JSONObject[$currentLevelKey]) { # Handle case in which the value is 'null' and hence has no type @@ -83,7 +83,7 @@ function ConvertTo-OrderedHashtable { foreach ($array in $arrayElements) { if ($array.Count -gt 1) { # Only sort for arrays with more than one item. Otherwise single-item arrays are casted - $array = $array | Sort-Object + $array = $array | Sort-Object -Culture 'en-US' } $arrayOutput += , (ConvertTo-OrderedHashtable -JSONInputObject ($array | ConvertTo-Json -Depth 99)) } @@ -97,13 +97,13 @@ function ConvertTo-OrderedHashtable { # Case: Primitive data types $primitiveElements = $JSONObject[$currentLevelKey] | Where-Object { $_.GetType().BaseType.Name -notin @('Array', 'Hashtable') } | ConvertTo-Json -Depth 99 | ConvertFrom-Json -AsHashtable -NoEnumerate -Depth 99 if ($primitiveElements.Count -gt 1) { - $primitiveElements = $primitiveElements | Sort-Object + $primitiveElements = $primitiveElements | Sort-Object -Culture 'en-US' } $arrayOutput += $primitiveElements if ($array.Count -gt 1) { # Only sort for arrays with more than one item. Otherwise single-item arrays are casted - $arrayOutput = $arrayOutput | Sort-Object + $arrayOutput = $arrayOutput | Sort-Object -Culture 'en-US' } $orderedLevel[$currentLevelKey] = $arrayOutput } diff --git a/avm/utilities/pipelines/sharedScripts/helper/Get-CrossReferencedModuleList.ps1 b/avm/utilities/pipelines/sharedScripts/helper/Get-CrossReferencedModuleList.ps1 index 0d34d96f61..f9031b160b 100644 --- a/avm/utilities/pipelines/sharedScripts/helper/Get-CrossReferencedModuleList.ps1 +++ b/avm/utilities/pipelines/sharedScripts/helper/Get-CrossReferencedModuleList.ps1 @@ -96,9 +96,9 @@ function Get-ReferenceObject { } return @{ - resourceReferences = $resultSet.resourceReferences | Sort-Object -Unique - remoteReferences = $resultSet.remoteReferences | Sort-Object -Unique - localPathReferences = $resultSet.localPathReferences | Sort-Object -Unique + resourceReferences = $resultSet.resourceReferences | Sort-Object -Culture 'en-US' -Unique + remoteReferences = $resultSet.remoteReferences | Sort-Object -Culture 'en-US' -Unique + localPathReferences = $resultSet.localPathReferences | Sort-Object -Culture 'en-US' -Unique } } #endregion @@ -155,7 +155,7 @@ function Get-CrossReferencedModuleList { $moduleTemplatePaths = (Get-ChildItem -Path $path -Recurse -File -Filter '*.bicep').FullName | Where-Object { # No files inthe [/utilities/tools/] folder and none in the [/tests/] folder $_ -notmatch '.*[\\|\/]tools[\\|\/].*|.*[\\|\/]tests[\\|\/].*' - } | Sort-Object + } | Sort-Object -Culture 'en-US' $templateMap = @{} foreach ($moduleTemplatePath in $moduleTemplatePaths) { $templateMap[$moduleTemplatePath] = Get-Content -Path $moduleTemplatePath diff --git a/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 b/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 index 356a552c48..b71fb9d849 100644 --- a/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 +++ b/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 @@ -76,7 +76,7 @@ function Get-SpecsAlignedResourceName { $rawProviderNamespace, $rawResourceType = $reducedResourceIdentifier -Split '[\/|\\]', 2 # e.g. 'keyvault' & 'vaults/keys' # Find provider namespace - $foundProviderNamespaceMatches = ($specs.Keys | Sort-Object) | Where-Object { $_ -like "Microsoft.$rawProviderNamespace*" } + $foundProviderNamespaceMatches = ($specs.Keys | Sort-Object -Culture 'en-US') | Where-Object { $_ -like "Microsoft.$rawProviderNamespace*" } if (-not $foundProviderNamespaceMatches) { $providerNamespace = "Microsoft.$rawProviderNamespace" @@ -86,7 +86,7 @@ function Get-SpecsAlignedResourceName { } # Find resource type - $innerResourceTypes = $specs[$providerNamespace].Keys | Sort-Object + $innerResourceTypes = $specs[$providerNamespace].Keys | Sort-Object -Culture 'en-US' $rawResourceTypeElem = $rawResourceType -split '[\/|\\]' $reducedResourceTypeElements = $rawResourceTypeElem | ForEach-Object { Get-ReducedWordString -StringToReduce $_ } diff --git a/avm/utilities/pipelines/sharedScripts/tokenReplacement/Convert-TokensInFileList.ps1 b/avm/utilities/pipelines/sharedScripts/tokenReplacement/Convert-TokensInFileList.ps1 index bcae7411d6..806041c122 100644 --- a/avm/utilities/pipelines/sharedScripts/tokenReplacement/Convert-TokensInFileList.ps1 +++ b/avm/utilities/pipelines/sharedScripts/tokenReplacement/Convert-TokensInFileList.ps1 @@ -70,7 +70,7 @@ function Convert-TokensInFileList { process { # Combine All Input Token Types, Remove Duplicates and Only Select entries with on empty values - $FilteredTokens = ($Tokens | Sort-Object -Unique).Clone() + $FilteredTokens = ($Tokens | Sort-Object -Culture 'en-US' -Unique).Clone() @($FilteredTokens.Keys) | ForEach-Object { if ([String]::IsNullOrEmpty($FilteredTokens[$_])) { $FilteredTokens.Remove($_) diff --git a/avm/utilities/pipelines/staticValidation/compliance/Set-PesterGitHubOutput.ps1 b/avm/utilities/pipelines/staticValidation/compliance/Set-PesterGitHubOutput.ps1 index 70e939e949..d28f09fa20 100644 --- a/avm/utilities/pipelines/staticValidation/compliance/Set-PesterGitHubOutput.ps1 +++ b/avm/utilities/pipelines/staticValidation/compliance/Set-PesterGitHubOutput.ps1 @@ -128,7 +128,7 @@ function Set-PesterGitHubOutput { '| Name | Error | Source |', '| :-- | :-- | :-- |' ) - foreach ($failedTest in ($failedTests | Sort-Object -Property { $PSItem.ExpandedName })) { + foreach ($failedTest in ($failedTests | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName })) { $intermediateNameElements = $failedTest.Path $intermediateNameElements[-1] = '**{0}**' -f $failedTest.ExpandedName @@ -175,7 +175,7 @@ function Set-PesterGitHubOutput { '| Name | Source |', '| :-- | :-- |' ) - foreach ($passedTest in ($passedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) { + foreach ($passedTest in ($passedTests | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName }) ) { $intermediateNameElements = $passedTest.Path $intermediateNameElements[-1] = '**{0}**' -f $passedTest.ExpandedName @@ -221,7 +221,7 @@ function Set-PesterGitHubOutput { '| Name | Reason | Source |', '| :-- | :-- | :-- |' ) - foreach ($skippedTest in ($skippedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) { + foreach ($skippedTest in ($skippedTests | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName }) ) { $intermediateNameElements = $skippedTest.Path $intermediateNameElements[-1] = '**{0}**' -f $skippedTest.ExpandedName @@ -269,7 +269,7 @@ function Set-PesterGitHubOutput { '| Name | Warning | Source |', '| :-- | :-- | :-- |' ) - foreach ($test in ($testsWithWarnings | Sort-Object -Property { $PSItem.ExpandedName }) ) { + foreach ($test in ($testsWithWarnings | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName }) ) { foreach ($warning in $test.StandardOutput.Warning) { $intermediateNameElements = $test.Path $intermediateNameElements[-1] = '**{0}**' -f $test.ExpandedName diff --git a/avm/utilities/pipelines/staticValidation/compliance/module.tests.ps1 b/avm/utilities/pipelines/staticValidation/compliance/module.tests.ps1 index 92e9b154c5..86e8253752 100644 --- a/avm/utilities/pipelines/staticValidation/compliance/module.tests.ps1 +++ b/avm/utilities/pipelines/staticValidation/compliance/module.tests.ps1 @@ -36,7 +36,7 @@ Import-Module (Join-Path $PSScriptRoot 'helper' 'helper.psm1') -Force $pathsToBuild = [System.Collections.ArrayList]@() $pathsToBuild += $moduleFolderPaths | ForEach-Object { Join-Path $_ 'main.bicep' } foreach ($moduleFolderPath in $moduleFolderPaths) { - if ($testFilePaths = ((Get-ChildItem -Path $moduleFolderPath -Recurse -Filter 'main.test.bicep').FullName | Sort-Object)) { + if ($testFilePaths = ((Get-ChildItem -Path $moduleFolderPath -Recurse -Filter 'main.test.bicep').FullName | Sort-Object -Culture 'en-US')) { $pathsToBuild += $testFilePaths } } @@ -533,7 +533,7 @@ Describe 'Module tests' -Tag 'Module' { } $incorrectParameters = @() - foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object)) { + foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object -Culture 'en-US')) { # Parameters in the object are formatted like # - tags # - customerManagedKey.keyVaultResourceId @@ -560,7 +560,7 @@ Describe 'Module tests' -Tag 'Module' { } $incorrectParameters = @() - foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object)) { + foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object -Culture 'en-US')) { $data = $templateFileParameters.$parameter.metadata.description if ($data -notmatch '(?s)^[A-Z][a-zA-Z]+\. .+\.$') { $incorrectParameters += $parameter @@ -584,7 +584,7 @@ Describe 'Module tests' -Tag 'Module' { } $incorrectParameters = @() - foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object)) { + foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object -Culture 'en-US')) { $data = $templateFileParameters.$parameter.metadata.description switch -regex ($data) { '^Conditional. .*' { @@ -605,7 +605,7 @@ Describe 'Module tests' -Tag 'Module' { ) $incorrectParameters = @() - foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object)) { + foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object -Culture 'en-US')) { $isRequired = Get-IsParameterRequired -TemplateFileContent $templateFileContent -Parameter $templateFileParameters.$parameter if (-not $isRequired) { @@ -1184,12 +1184,12 @@ Describe 'Governance tests' { # Should be at correct location $incorrectLines = @() - foreach ($finding in (Compare-Object $listedModules ($listedModules | Sort-Object) -SyncWindow 0)) { + foreach ($finding in (Compare-Object $listedModules ($listedModules | Sort-Object -Culture 'en-US') -SyncWindow 0)) { if ($finding.SideIndicator -eq '<=') { $incorrectLines += $finding.InputObject } } - $incorrectLines = $incorrectLines | Sort-Object -Unique + $incorrectLines = $incorrectLines | Sort-Object -Culture 'en-US' -Unique $incorrectLines.Count | Should -Be 0 -Because ('the number of modules that are not in the correct alphabetical order in the issue template should be zero ([ref](https://azure.github.io/Azure-Verified-Modules/specs/bicep/#id-bcpnfr15---category-contributionsupport---avm-module-issue-template-file)).
However, the following incorrectly located lines were found:
{0}
' -f ($incorrectLines -join '
')) } @@ -1203,7 +1203,7 @@ Describe 'Test file tests' -Tag 'TestTemplate' { foreach ($moduleFolderPath in $moduleFolderPaths) { if (Test-Path (Join-Path $moduleFolderPath 'tests')) { - $testFilePaths = (Get-ChildItem -Path $moduleFolderPath -Recurse -Filter 'main.test.bicep').FullName | Sort-Object + $testFilePaths = (Get-ChildItem -Path $moduleFolderPath -Recurse -Filter 'main.test.bicep').FullName | Sort-Object -Culture 'en-US' foreach ($testFilePath in $testFilePaths) { $testFileContent = Get-Content $testFilePath $resourceTypeIdentifier = ($moduleFolderPath -split '[\/|\\]{1}avm[\/|\\]{1}(res|ptn)[\/|\\]{1}')[2] -replace '\\', '/' # 'avm/res|ptn//' would return '/' @@ -1346,7 +1346,7 @@ Describe 'API version tests' -Tag 'ApiCheck' { $nestedResources = Get-NestedResourceList -TemplateFileContent $templateFileContent | Where-Object { $_.type -notin @('Microsoft.Resources/deployments') -and $_ - } | Select-Object 'Type', 'ApiVersion' -Unique | Sort-Object Type + } | Select-Object 'Type', 'ApiVersion' -Unique | Sort-Object -Culture 'en-US' -Property 'Type' foreach ($resource in $nestedResources) { @@ -1449,7 +1449,7 @@ Describe 'API version tests' -Tag 'ApiCheck' { $approvedApiVersions += $resourceTypeApiVersions | Where-Object { $_ -notlike '*-preview' } | Select-Object -Last 5 } - $approvedApiVersions = $approvedApiVersions | Sort-Object -Unique -Descending + $approvedApiVersions = $approvedApiVersions | Sort-Object -Culture 'en-US' -Unique -Descending if ($approvedApiVersions -notcontains $TargetApi) { # Using a warning now instead of an error, as we don't want to block PRs for this. diff --git a/avm/utilities/pipelines/staticValidation/psrule/Set-PSRuleGitHubOutput.ps1 b/avm/utilities/pipelines/staticValidation/psrule/Set-PSRuleGitHubOutput.ps1 index 15a8561bf2..2bbffee2a1 100644 --- a/avm/utilities/pipelines/staticValidation/psrule/Set-PSRuleGitHubOutput.ps1 +++ b/avm/utilities/pipelines/staticValidation/psrule/Set-PSRuleGitHubOutput.ps1 @@ -46,8 +46,8 @@ function Set-PSRuleGitHubOutput { return '' } else { $results = Import-Csv -Path $inputFilePath - $passedRules += $results | Where-Object { $_.Outcome -EQ 'Pass' } | Sort-Object -Property 'TargetName', 'RuleName' -Unique - $failedRules += $results | Where-Object { $_.Outcome -EQ 'Fail' } | Sort-Object -Property 'TargetName', 'RuleName' -Unique + $passedRules += $results | Where-Object { $_.Outcome -EQ 'Pass' } | Sort-Object -Culture 'en-US' -Property 'TargetName', 'RuleName' -Unique + $failedRules += $results | Where-Object { $_.Outcome -EQ 'Fail' } | Sort-Object -Culture 'en-US' -Property 'TargetName', 'RuleName' -Unique ###################### # Set output content # diff --git a/avm/utilities/tools/Invoke-WorkflowsForBranch.ps1 b/avm/utilities/tools/Invoke-WorkflowsForBranch.ps1 index 848b9864e6..cde84fa56b 100644 --- a/avm/utilities/tools/Invoke-WorkflowsForBranch.ps1 +++ b/avm/utilities/tools/Invoke-WorkflowsForBranch.ps1 @@ -285,6 +285,6 @@ function Invoke-WorkflowsForBranch { if ($gitHubWorkflowBadges.Count -gt 0) { Write-Verbose 'GitHub Workflow Badges' -Verbose Write-Verbose '======================' -Verbose - Write-Verbose ($gitHubWorkflowBadges | Sort-Object | Out-String) -Verbose + Write-Verbose ($gitHubWorkflowBadges | Sort-Object -Culture 'en-US' | Out-String) -Verbose } } diff --git a/avm/utilities/tools/Test-ModuleLocally.ps1 b/avm/utilities/tools/Test-ModuleLocally.ps1 index c4595eb892..f29c2c90c1 100644 --- a/avm/utilities/tools/Test-ModuleLocally.ps1 +++ b/avm/utilities/tools/Test-ModuleLocally.ps1 @@ -216,7 +216,7 @@ function Test-ModuleLocally { foreach ($testFilePath in $moduleTestFiles) { $tokenConfiguration.FilePathList += (Get-LocallyReferencedFileList -FilePath $testFilePath) } - $tokenConfiguration.FilePathList = $tokenConfiguration.FilePathList | Sort-Object -Unique + $tokenConfiguration.FilePathList = $tokenConfiguration.FilePathList | Sort-Object -Culture 'en-US' -Unique # Add other template files as they may contain the 'moduleVersion' $tokenConfiguration.FilePathList += (Get-ChildItem -Path $moduleRoot -Recurse -File).FullName | Where-Object { $_ -match '.+(main.json|main.bicep)$' }