如何强制 Powershell 脚本运行特定版本

2024-01-10

我的计算机上同时安装了 Powershell 5.1 和 Powershell 7.0,并且我尝试运行必须在 Powershell 7.0 中运行的脚本。如何使脚本在特定版本中运行。


另一种选择是使用#Requires 语句

#Requires -Version 7.0

这是微软支持的参考

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何强制 Powershell 脚本运行特定版本 的相关文章

随机推荐