Skip to content

Fix syntax error in Windows PowerShell #13355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tools/Az.Tools.Installer/Az.Tools.Installer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Az.Tools.Installer.psm1'

# Version number of this module.
ModuleVersion = '0.1.0'
ModuleVersion = '0.1.1'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down Expand Up @@ -109,7 +109,8 @@
# IconUri = ''

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

# Prerelease string of this module
# Prerelease = ''
Expand Down
8 changes: 4 additions & 4 deletions tools/Az.Tools.Installer/exports/Update-AzModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function Update-AzModule {
Write-Debug "Powershell $ppsedition Version $($PSVersionTable.PSVersion)"

if ($ppsedition -eq "Core") {
$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
$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
$allPahts = ($allPahts | Select-String -Pattern "WindowsPowerShell")
if ($allPahts) {
Write-Warning "Az modules are also installed in WindowsPowerShell. Please update them using WindowsPowerShell."
Expand All @@ -96,9 +96,9 @@ function Update-AzModule {
if($allToUpdate) {
Write-Host -ForegroundColor DarkGreen "The modules to Update:$($allToUpdate | Out-String)"

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

foreach ($module in $allToUpdateReordered) {
if (-not $module) {
Expand Down
8 changes: 4 additions & 4 deletions tools/Az.Tools.Installer/internal/Get-AzModuleUpdateList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function Get-AzModuleUpdateList {
Write-Debug "Retrieving installed Az modules"
$installModules = @{}
try {
(PowerShellGet\Get-InstalledModule -Name "Az*" -ErrorAction Stop).Where({
PowerShellGet\Get-InstalledModule -Name "Az*" -ErrorAction Stop | Where-Object {
($_.Author -eq 'Microsoft Corporation' -or $_.CompanyName -eq 'Microsoft Corporation') -and ($_.Name -match "Az(\.[a-zA-Z0-9]+)?$")
}) | ForEach-Object {
} | ForEach-Object {
$installModules[$_.Name] = @()
}
}
Expand Down Expand Up @@ -105,10 +105,10 @@ function Get-AzModuleUpdateList {

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

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

If (-not $modulesToUpdate) {
Expand Down