Skip to content

Commit ba0cb54

Browse files
authored
Fix syntax error in Windows PowerShell (#13355)
1 parent 4bf6704 commit ba0cb54

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

tools/Az.Tools.Installer/Az.Tools.Installer.psd1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'Az.Tools.Installer.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.1.0'
15+
ModuleVersion = '0.1.1'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'
@@ -109,7 +109,8 @@
109109
# IconUri = ''
110110

111111
# ReleaseNotes of this module
112-
ReleaseNotes = '* the first preview release'
112+
ReleaseNotes = '* Fix wildcard error in Install-AzModule
113+
* Fix syntax errors in Windows Powershell'
113114

114115
# Prerelease string of this module
115116
# Prerelease = ''

tools/Az.Tools.Installer/exports/Update-AzModule.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function Update-AzModule {
7777
Write-Debug "Powershell $ppsedition Version $($PSVersionTable.PSVersion)"
7878

7979
if ($ppsedition -eq "Core") {
80-
$allPahts = (Microsoft.PowerShell.Core\Get-Module -Name "Az*" -ListAvailable -ErrorAction Stop).Where({$_.Author -eq "Microsoft Corporation" -and $_.Name -match "Az(\.[a-zA-Z0-9]+)?$"}).Path
80+
$allPahts = (Microsoft.PowerShell.Core\Get-Module -Name "Az*" -ListAvailable -ErrorAction Stop | Where-Object {$_.Author -eq "Microsoft Corporation" -and $_.Name -match "Az(\.[a-zA-Z0-9]+)?$"}).Path
8181
$allPahts = ($allPahts | Select-String -Pattern "WindowsPowerShell")
8282
if ($allPahts) {
8383
Write-Warning "Az modules are also installed in WindowsPowerShell. Please update them using WindowsPowerShell."
@@ -96,9 +96,9 @@ function Update-AzModule {
9696
if($allToUpdate) {
9797
Write-Host -ForegroundColor DarkGreen "The modules to Update:$($allToUpdate | Out-String)"
9898

99-
$allToUpdateReordered = @() + $allToUpdate.Where({$_.Name -eq "Az"})
100-
$allToUpdateReordered += $allToUpdate.Where({$_.Name -ne "Az" -and $_.Name -ne "Az.Accounts"})
101-
$allToUpdateReordered += $allToUpdate.Where({$_.Name -eq "Az.Accounts"})
99+
$allToUpdateReordered = @() + ($allToUpdate | Where-Object {$_.Name -eq "Az"})
100+
$allToUpdateReordered += $allToUpdate | Where-Object {$_.Name -ne "Az" -and $_.Name -ne "Az.Accounts"}
101+
$allToUpdateReordered += $allToUpdate | Where-Object {$_.Name -eq "Az.Accounts"}
102102

103103
foreach ($module in $allToUpdateReordered) {
104104
if (-not $module) {

tools/Az.Tools.Installer/internal/Get-AzModuleUpdateList.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ function Get-AzModuleUpdateList {
3333
Write-Debug "Retrieving installed Az modules"
3434
$installModules = @{}
3535
try {
36-
(PowerShellGet\Get-InstalledModule -Name "Az*" -ErrorAction Stop).Where({
36+
PowerShellGet\Get-InstalledModule -Name "Az*" -ErrorAction Stop | Where-Object {
3737
($_.Author -eq 'Microsoft Corporation' -or $_.CompanyName -eq 'Microsoft Corporation') -and ($_.Name -match "Az(\.[a-zA-Z0-9]+)?$")
38-
}) | ForEach-Object {
38+
} | ForEach-Object {
3939
$installModules[$_.Name] = @()
4040
}
4141
}
@@ -105,10 +105,10 @@ function Get-AzModuleUpdateList {
105105

106106
Write-Debug "The modules to check for update: $($modules.Name)"
107107

108-
$modulesToUpdate = $modules.Where({ !$installModules.ContainsKey($_.Name) -or !$installModules[$_.Name] -or [Version]($_.Version) -gt [Version]$installModules[$_.Name][0].Item1 })
108+
$modulesToUpdate = $modules | Where-Object { !$installModules.ContainsKey($_.Name) -or !$installModules[$_.Name] -or [Version]($_.Version) -gt [Version]$installModules[$_.Name][0].Item1 }
109109
if ("Az" -eq ($modulesToUpdate | Select-Object -First 1).Name) {
110110
$first, $rest = $modulesToUpdate
111-
$modulesToUpdate = (@() + $rest + $first)
111+
$modulesToUpdate = (@() + $rest + $first) | Where-Object {$_ -ne $null}
112112
}
113113

114114
If (-not $modulesToUpdate) {

0 commit comments

Comments
 (0)