Skip to content
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

Warn of PowerShell 2.0 deprecation #186

Merged
merged 4 commits into from
May 14, 2015
Merged

Conversation

theaquamarine
Copy link
Collaborator

Closes #163

if (Get-Module posh-git) { return }

if ($PSVersionTable.PSVersion.Major -lt 3 -and !$NoVersionWarn) {
Write-Warning ("posh-git support for PowerShell 2.0 is deprecated; you have version $($Host.Version).`n" +
Copy link
Owner

Choose a reason for hiding this comment

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

Let's use $($PSVersionTable.PSVersion) instead of $($Host.Version), since the latter will only match for the standard host (not in the NuGet console, for example).

@dahlbyk
Copy link
Owner

dahlbyk commented May 14, 2015

So sorry for the delay in looking at this. Looks great other than my comment on $Host.

@@ -30,7 +30,7 @@ Install-Module posh-git
Installing (manual)
-------------------

0. Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion
0. Verify you have PowerShell 2.0 or better with `$PSVersionTable.PSVersion`. PowerShell 3.0 is preferred as 2.0 support is deprecated.
Copy link
Owner

Choose a reason for hiding this comment

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

Bah, I think I just merged a conflict (#171).

Allow Powershell 2 support deprecation warning to be suppressed by
importing the module with a true value as an argument.

The ability to pass arguments through Import-Module is pretty limited,
accepting only positional arguments, but it still seems a preferable
option to environment variables or asking users to modify posh-git
directly.

Closes dahlbyk#163
@theaquamarine
Copy link
Collaborator Author

Version check fixed, conflict fixed.

dahlbyk added a commit that referenced this pull request May 14, 2015
Warn of PowerShell 2.0 deprecation
@dahlbyk dahlbyk merged commit f948f5a into dahlbyk:master May 14, 2015
@dahlbyk
Copy link
Owner

dahlbyk commented May 14, 2015

Perfect, thanks!

@haacked haacked mentioned this pull request Mar 2, 2016
@dingmanyao
Copy link

Solve the problem of warning, can modified first line of the posh-git.psm1:
param([switch]$NoVersionWarn = $false) ==>param([switch]$NoVersionWarn = $true)
image
这个问题是因为PowerShell3.0需要软件支持,你的系统没有所以无法升级到3.0,但是使用2.0就有警告,那么两种办法:1.去掉警告,继续使用2.0,不要升级,用上面的办法就可以;2.打开https://www.microsoft.com/en-us/download/details.aspx?id=34595 下载需要的软件,再升级。

@dahlbyk
Copy link
Owner

dahlbyk commented Jun 25, 2016

Solve the problem of warning, can modified first line of the posh-git.psm1:

Rather than modify the module, I would suggest updating profile.example.ps1 (or copy its contents into your own $PROFILE) to change the Import-Module line to:

Import-Module .\posh-git -ArgumentList $true

@dahlbyk dahlbyk mentioned this pull request Dec 29, 2016
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate PowerShell 2.0 Support
3 participants