Windows Powershell Foreach 循环
下面举两个例子:
$array=7..10
foreach($nin$array)
{
$n*$n
}
#49
#64
#81
#100
foreach($fileindirc:\windows)
{
if($file.Length-gt1mb)
{
$File.Name
}
}
#explorer.exe
#WindowsUpdate.log
这里只为了演示foreach,其实上面的第二个例子可以用Foreach-Object更简洁。
PSC:\Powershell>dirC:\Windows|where{$_.length-gt1mb}|foreach-object{$_.Name}
explorer.exe
WindowsUpdate.log
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短