那么Powershell PSC1 文件有什么特别之处呢? [英] So what is special about Powershell PSC1 files?
问题描述
在我的 PowerShell 快捷方式上,我有以下内容:
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\""
然而,我更愿意添加管理单元的注册并在我的配置文件中运行 PowerCLI 环境的初始化.
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"
然而,使用此方法无法再使用 Get-VICommand.为什么?
Yet, the Get-VICommand is no longer available using this method. Why?
推荐答案
PSC1 文件是PowerShell 控制台文件".它们是 XML 配置文件,告诉 PowerShell 自动加载哪些管理单元.另一种方法是在 Profile.ps1
脚本中调用 Import-Module
或 Add-PSSnapin
.
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
or Add-PSSnapin
in your Profile.ps1
script.
您可以使用 Export-Console
创建自己的 psc1 文件.
You can create your own psc1 files using Export-Console
.
这篇关于那么Powershell PSC1 文件有什么特别之处呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!