$($_.)作用

1 $a=get-process
2 foreach ($b in $a)
3 {
4  write-host "hello: $($b.id)"
5 }

返回结果:

hello: 2536
hello: 3528
hello: 2316
hello: 608
hello: 732
hello: 1392
hello: 2456
hello: 2680
hello: 5940
hello: 3540

 

1 $a=get-process
2 foreach ($b in $a)
3 {
4  write-host "hello: $b.id"
5 }

返回结果:

hello: System.Diagnostics.Process (vmware-tray).id
hello: System.Diagnostics.Process (vmware-usbarbitrator64).id
hello: System.Diagnostics.Process (wininit).id
hello: System.Diagnostics.Process (winlogon).id
hello: System.Diagnostics.Process (wlanext).id
hello: System.Diagnostics.Process (WmiPrvSE).id
hello: System.Diagnostics.Process (WmiPrvSE).id
hello: System.Diagnostics.Process (WmiPrvSE).id
hello: System.Diagnostics.Process (wmpnetwk).id

posted on 2014-08-17 10:31  momingliu11  阅读(436)  评论(0编辑  收藏  举报