Powershell:如何将system.object值转换为Array值

时间:2019-03-14 15:38:09

标签: powershell

$t3 = Get-Nabc | % { $_.name }
Write-Host $t3.name
Write-Host $t3.gettype()

输出为

A B C D E F G H I J 
System.Object[]

问题:-我想将输出输出到数组并与字符串进行比较

$t3 = Get-Nabc | % { $_.name }
$a1 = $t3

for ($i=0; $i -le $t3.length; $i++) {
    if('A' -in $a1[0]) {
        Write-Host 'Match'
    }
    else {
        Write-Host 'Not Match'
    }
}

但是代码不起作用。如何将值从system.object转换/复制到数组?

0 个答案:

没有答案