Skip to content

Commit b2794a2

Browse files
authored
Merge pull request #5413 from maddieclayton/deprecation
Add deprecation for PowerShell 3/4 to Profile psm1
2 parents e57664c + 055559b commit b2794a2

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/ResourceManager/Profile/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Added deprecation warning for PowerShell 3 and 4
2122
* `Add-AzureRmAccount` has been renamed as `Connect-AzureRmAccount`; an alias has been added for the old cmdlet name, and other aliases (`Login-AzAccount` and `Login-AzureRmAccount`) have been redirected to the new cmdlet name.
2223
* `Remove-AzureRmAccount` has been renamed as `Disconnect-AzureRmAccount`; an alias has been added for the old cmdlet name, and other aliases (`Logout-AzAccount` and `Logout-AzureRmAccount`) have been redirected to the new cmdlet name.
2324
* Corrected Resource Strings to use Connect-AzureRmAccount instead of Login-AzureRmAccount

tools/AzureRM.Example.psm1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ if ($PSVersionTable.PSVersion.Major -ge 5)
3838
Register-ArgumentCompleter -CommandName $_.Command -ParameterName $_.Parameter -ScriptBlock $sb
3939
}
4040
}
41+
else
42+
{
43+
%PSVersionDeprecationMessage%
44+
}
4145

4246
$FilteredCommands = %DEFAULTRGCOMMANDS%
4347

tools/UpdateModules.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ function Create-ModulePsm1
6767
$template = $template -replace "%DATE%", [string](Get-Date)
6868
$template = $template -replace "%IMPORTED-DEPENDENCIES%", $importedModules
6969

70+
if ($ModulePath -like "*Profile*")
71+
{
72+
$WarningMessage = "`"PowerShell version 3 and 4 will no longer be supported starting in May 2018. Please update to the latest version of PowerShell 5.1`""
73+
$template = $template -replace "%PSVersionDeprecationMessage%",
74+
"`$SpecialFolderPath = Join-Path -Path ([Environment]::GetFolderPath('ApplicationData')) -ChildPath 'Windows Azure Powershell' `
75+
`$DeprecationFile = Join-Path -Path `$SpecialFolderPath -ChildPath 'PSDeprecationWarning.txt' `
76+
if (!(Test-Path `$DeprecationFile)) { `
77+
Write-Warning $WarningMessage `
78+
try { `
79+
$WarningMessage | Out-File -FilePath `$DeprecationFile `
80+
} catch {} `
81+
}"
82+
}
83+
else
84+
{
85+
$template = $template -replace "%PSVersionDeprecationMessage%", ""
86+
}
87+
7088
$completerCommands = Find-CompleterAttribute -ModuleMetadata $ModuleMetadata -ModulePath $ModulePath -IsRMModule $IsRMModule
7189
$template = $template -replace "%COMPLETERCOMMANDS%", $completerCommands
7290

0 commit comments

Comments
 (0)