Skip to content

Add deprecation for PowerShell 3/4 to Profile psm1 #5413

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 7 commits into from
Feb 6, 2018
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
1 change: 1 addition & 0 deletions src/ResourceManager/Profile/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* Added deprecation warning for PowerShell 3 and 4
* `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.
* `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.
* Corrected Resource Strings to use Connect-AzureRmAccount instead of Login-AzureRmAccount
Expand Down
4 changes: 4 additions & 0 deletions tools/AzureRM.Example.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ if ($PSVersionTable.PSVersion.Major -ge 5)
Register-ArgumentCompleter -CommandName $_.Command -ParameterName $_.Parameter -ScriptBlock $sb
}
}
else
{
%PSVersionDeprecationMessage%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to save a file in their user directory to indicate that we have displayed this message, simila to the pattern we use for enabling/disabling data collection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markcowl is this what you had in mind?

}

$FilteredCommands = %DEFAULTRGCOMMANDS%

Expand Down
18 changes: 18 additions & 0 deletions tools/UpdateModules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ function Create-ModulePsm1
$template = $template -replace "%DATE%", [string](Get-Date)
$template = $template -replace "%IMPORTED-DEPENDENCIES%", $importedModules

if ($ModulePath -like "*Profile*")
{
$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`""
$template = $template -replace "%PSVersionDeprecationMessage%",
"`$SpecialFolderPath = Join-Path -Path ([Environment]::GetFolderPath('ApplicationData')) -ChildPath 'Windows Azure Powershell' `
`$DeprecationFile = Join-Path -Path `$SpecialFolderPath -ChildPath 'PSDeprecationWarning.txt' `
if (!(Test-Path `$DeprecationFile)) { `
Write-Warning $WarningMessage `
try { `
$WarningMessage | Out-File -FilePath `$DeprecationFile `
} catch {} `
}"
}
else
{
$template = $template -replace "%PSVersionDeprecationMessage%", ""
}

$completerCommands = Find-CompleterAttribute -ModuleMetadata $ModuleMetadata -ModulePath $ModulePath -IsRMModule $IsRMModule
$template = $template -replace "%COMPLETERCOMMANDS%", $completerCommands

Expand Down