Skip to content

Commit 9382534

Browse files
authored
Add warning message if user using PowerShell 6 or PowerShell 7 < 7.0.6 (#15012)
1 parent fc365f6 commit 9382534

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tools/UpdateModules.psm1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ function New-ModulePsm1 {
105105
{
106106
$template = $template -replace "%AZURECOREPREREQUISITE%", ""
107107
}
108+
elseif($file.BaseName -ieq 'Az.Accounts')
109+
{
110+
$template = $template -replace "%AZURECOREPREREQUISITE%",
111+
@"
112+
if (%ISAZMODULE% -and (`$PSEdition -eq 'Core'))
113+
{
114+
if (`$PSVersionTable.PSVersion -lt [Version]'6.2.4')
115+
{
116+
throw "Current Az version doesn't support PowerShell Core versions lower than 6.2.4. Please upgrade to PowerShell Core 6.2.4 or higher."
117+
}
118+
if (`$PSVersionTable.PSVersion -lt [Version]'7.0.6')
119+
{
120+
Write-Warning "This version of Az.Accounts is only supported on Windows PowerShell 5.1 and PowerShell 7.0.6 or greater, open https://aka.ms/install-powershell to learn how to upgrade. For further information, go to http://aka.ms/azpslifecyle."
121+
}
122+
}
123+
"@
124+
}
108125
else
109126
{
110127
$template = $template -replace "%AZURECOREPREREQUISITE%",

0 commit comments

Comments
 (0)