为什么输出与控制台

时间:2017-02-06 14:50:51

标签: powershell

为什么我的输出有差异?

$f = Get-WindowsFeature
$f[1].GetType()
$f[1]

输出

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array

Name                      : ADCS-Cert-Authority
DisplayName               : Certification Authority
Description               : Certification Authority (CA) is used to issue and manage certificates. Multiple CAs can be linked to form a public key infrastructure.
...

$f = Get-WindowsFeature   
$f[1]

输出

Display Name                                    Name                       Install State
------------                                    ----                       -------------
[ ] Certification Authority                     ADCS-Cert-Authority            Available

如果不删除$lines.GetType(),也会从$f[1]获得更详细的输出。

$f = Get-WindowsFeature
$f[1]

$lines = Get-Content featuresinarray.txt | Where {$_ -notmatch '^\s+$'} 
$lines.GetType()

输出

Display Name                                    Name                       Install State
------------                                    ----                       -------------
[ ] Certification Authority                     ADCS-Cert-Authority            Available

Module                     : CommonLanguageRuntimeLibrary
Assembly                   : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
TypeHandle                 : System.RuntimeTypeHandle
DeclaringMethod            : 
BaseType                   : System.Array

但现在如果我在$f.GetType()后添加$f = Get-WindowsFeature,我会得到$lines.GetType()$f.GetType()的短输出:

True     True     Object[]                                 System.Array

如果我在$f.GetType()之后添加$lines.GetType(),那么我在输出中有2次详细的Array类输出。那么为什么会这样呢?

0 个答案:

没有答案