根据这篇TechNet文章关于PowerShell型加速器的说法,有几十种类型别名被称为类型加速器。实际上,下面的命令
[psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::get在我的系统上返回80个加速器。
然而,它的缩写[accelerators]::get似乎失败了:
找不到类型的加速器。确保加载了包含此类型的程序集。一行:1字符:1
在发出命令之前,我还尝试用System.Management.Automation.TypeAccelerators动态加载[System.Reflection.Assembly]::LoadWithPartialName("System.Management.Automation.TypeAccelerators")程序集,但仍然失败。
$PSVersionTable返回以下数据:
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.18728
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2操作系统是Windows 7 x64。
如何以加速的方式获得PowerShell类型的加速器列表?
发布于 2018-02-09 10:11:34
我知道这篇文章说它在PowerShell 3.0中是默认存在的,但是我从来没有见过它在任何其他版本中出现过,很可能是在4.0版本中再次被删除。
您需要自己添加:
$TAType = [psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")
$TAType::Add('accelerators',$TAType)
# this now works
[accelerators]::Gethttps://stackoverflow.com/questions/48703289
复制相似问题