那么 Powershell PSC1 文件有什么特别之处呢?
在我的 PowerShell 快捷方式上,我有以下内容:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\""
然而,我更愿意添加管理单元的注册并将 PowerCLI 环境的 init 运行到我的配置文件中。
因此,在我的配置文件中,我添加了以下内容:
Add-PSSnapin VMware.VimAutomation.Core
& "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
然而,使用此方法不再可用 Get-VICommand。为什么?
On my PowerShell shortcut I have the following:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\""
Yet, I would prefer to add the registration of snapins and to run the init of the PowerCLI environment to my profile.
So in my profile I add the following:
Add-PSSnapin VMware.VimAutomation.Core
& "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
Yet, the Get-VICommand is no longer available using this method. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PSC1 文件是“PowerShell 控制台文件”。它们是 XML 配置文件,告诉 PowerShell 自动加载哪些管理单元。另一种方法是在
Profile.ps1
脚本中调用Import-Module
或Add-PSSnapin
。您可以使用
Export-Console
创建自己的 psc1 文件。PSC1 files are "PowerShell Console files." They are XML configuration files that tell PowerShell which snapins to load automatically. The other way to do that would be to call
Import-Module
orAdd-PSSnapin
in yourProfile.ps1
script.You can create your own psc1 files using
Export-Console
.尝试这样:
Try like this: