function getinfo {
$strComputer = "localhost"
$colItems = GWMI -cl "Win32_NetworkAdapterConfiguration" -name "root\CimV2" -comp $strComputer -filter "IpEnabled = TRUE"
$Items1 = $colItems | Select DHCPServer, Caption, DNSHostName, IPAddress
$Items2 = $colItems | Select ServiceName, MacAddress, IPSubnet, InterfaceIndex
}
$objects = (New-Object PSObject |
add-member -pass NoteProperty "DHCP Server" $Items1.DHCPServer |
add-member -pass NoteProperty "IP Address" $Items1.IPAddress |
add-member -passthru NoteProperty "Mac Address" $Items2.MacAddress |
add-member -passthru NoteProperty "IP Subnet" $Items2.IPSubnet
)
$objects | ConvertTo-Json
-pass
&-passthru
キーについて混乱しています。違いは何ですか?-passthru
また、 for を使用すると何も入力されないのはなぜ$Items1
ですか?