Skip to content
mnaoumov.dev
Go back

WTF_ PowerShell 3 _ Cygwin

I found some WTF I cannot explain.

I have PowerShell 3 installed. But I have ability to run PowerShell 2 host

C:\Users\Michael>PowerShell -Version 2
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Michael> $host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

But if I do the same from Cygwin it does not work properly

$ PowerShell -Version 2
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Michael> $host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      -1     -1

WTF? Why it is still running PowerShell 3 ?!!

Moreover, I even tried to call cmd in between

$ cmd
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Michael>PowerShell -Version 2
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Michael> $host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      -1     -1

The same effect..

Does anyone know why that happens?!

It very annoying, especially because of the bug with breakpoints.

So far I could not find a way how to run PowerShell 2 from my machine, and I have to use VM for that… Very annoying!

If you curious why I need to run PowerShell from Cygwin, it is because of the git hooks I am writing. To develop server-side hooks I write PowerShell script, and because of the problem described above, I cannot use my nice trick with breakpoints

UPD: Raised question on stackoverflow


Share this post on:

Previous Post
Useful git hooks - Part 4
Next Post
PowerShell 3 bug with stack trace