早期版本的Powershell与更高版本相比缺少哪些主要内容?

时间:2015-05-04 16:56:18

标签: powershell powershell-v2.0 powershell-v3.0 powershell-v4.0 powershell-v5.0

我正在寻找一种历史课。我是PowerShell的后来者。我在版本4上学到了很多我正在考虑在版本兼容性很重要的地方使用的命令行开关。我运行powershell -version 3时,大多数单元测试都在通过。另一方面,当我跑powershell -version 2时,有一片红海。我不想盲目地重新设计我的代码库以试图使它对PowerShell的v4之前的版本友好,而是希望能够理解这将带来什么。

some posts说明版本之间的某些差异,但我还没有发现任何规范,也没有找到任何采取追溯视角来进行代码库向后兼容。

以下是我的具体问题:

  1. 早期版本的PowerShell中缺少的主要内容是为以后的版本编写的代码可能依赖于什么?

  2. PowerShell本身的版本是否向后兼容?也就是说,如果一个编写良好的脚本在版本2上正确运行,我可以期望它在版本3,4和5上运行时的行为方式相同吗?

1 个答案:

答案 0 :(得分:1)

  1. This question is too broad to get a good answer. I would suggest reading What's New in Windows PowerShell to get the highlights of what's changed.
  2. PowerShell is backwards compatible with scripts written for earlier version of PowerShell. I won't say 100%, but I can't remember having heard of any problems. Newer versions have extended and simplified existing cmdlets and introduced a lot of improvements, but AFAIK nothing has been removed or broken. Even Snap-ins are still supported in 5.0 even though they were replaced by modules in PowerShell 2.0.