技术控

    今日:0| 主题:63445
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Saying Farewell to Snapins!

[复制链接]
与阿妹共舞 发表于 2016-12-1 04:46:31
176 7
One of the key improvements to the VMware PowerCLI 6.5 R1 release is the absence of PowerShell snapins. All of the remaining snapins have been converted to modules!
  Snapin History

  If you don’t know why this is such a big deal, let me take a second to cover some history on snapins. Going back to the days of PowerShell version 1, snapins were the only way to extend the shell, or add additional features and functionalities. The issue with snapins begin due to how they can only be written in a .NET programming language and then have to be assembled before being handed off to the user. Then, once the user has them, the issues continue due to the snapins having to be installed and registered to each individual system a user wishes to use them on. Snapins also lack the ability to explicitly define dependencies, this causes issues for a product like PowerCLI which is comprised of several individual components.
  PowerShell version 2 introduced modules, which resolved a majority of those issues. Modules can still be written in any .NET programming language, or can even be written in PowerShell itself! Modules are mobile and don’t require any registrations. Once the modules are in hand, they can be referenced automatically by placing them in one of the proper folders or by specifying the directory path to where they reside for each system requiring access.
  Finding Snapins

  This change in architecture introduces an issue for already created scripts which are trying to load the old VMware snapins. Instead of performing something that looks like:
  Add-PSSnapin –Name VM*
  We’re recommending a replacement from that command to this command:
  Get-Module –ListAvailable VM* | Import-Module
   We’re not going to leave the rest to you to handle. There’s some functions which have been added to the PowerCLI Community Repository which will point out which scripts contain that line. There’s also a function which can comment out that line and add the new recommended command. These functions are available within the Update_PowerCLI_Scripts.ps1 script .
  The first function is “Get-PowerCLISnapinUse” and will show what scripts (.ps1 extensioned) include the string “Add-PSSnapin*VM*” and will display the file name, line where the string resides, path to the directory, and the full path of the file.
   

Saying Farewell to Snapins!

Saying Farewell to Snapins!

  The second function is “Update-PowerCLISnapinUse” and is based around adding the new Import-Module command and commenting that string out.
   

Saying Farewell to Snapins!

Saying Farewell to Snapins!

  Additionally, if you’ve already updated your version of PowerCLI, you may have noticed the installation directory has changed as well. If you have the “Initialize-PowerCLIEnvironment” script hardcoded into your scripts, there are also some functions to handle that as well. The functions for that are done by way of “Get-PowerCLIInitialization” and “Update-PowerCLIInitialization”. These functions work similarly to the above, however the “Update-PowerCLIInitialization” function just updates the directory path and does not comment anything out.
  Conclusion

  VMware PowerCLI moving over to be completely modules is a huge accomplishment in this newest release. As always, it’s backwards compatible and we recommend upgrading to the latest version.
   You can find the PowerCLI 6.5 Release 1 downloadHERE.
看着帅锅犯二鸟 发表于 2016-12-1 14:46:11
楼主不许动,我是来抢沙发的,沙发没有,板凳也行!
回复 支持 反对

使用道具 举报

500919 发表于 2016-12-1 22:41:01
画面太美我不敢看
回复 支持 反对

使用道具 举报

putihan 发表于 2016-12-1 23:13:39
在职场中就应该像柯南那样,有一种我走到哪就让别人死到哪的霸气。
回复 支持 反对

使用道具 举报

Fran丶 发表于 2016-12-2 03:27:52
失去某人,最糟糕的莫过于,他近在身旁,却犹如远在天边.
回复 支持 反对

使用道具 举报

new5201314 发表于 2016-12-2 05:33:26
心里只有你一个频道,最可恨的是还没有广告。
回复 支持 反对

使用道具 举报

萘小萘 发表于 2016-12-2 14:10:59
垃圾内容,路过为证。
回复 支持 反对

使用道具 举报

sukuyan 发表于 2016-12-7 14:37:57
楼主辛苦了,鼓励一下
回复 支持 反对

使用道具 举报

我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/c.CoLaBug.com ( 粤ICP备05003221号 | 粤公网安备 44010402000842号 )

© 2001-2017 Comsenz Inc.

返回顶部 返回列表