欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Windows Powershell Foreach 循環(huán)

 更新時間:2014年10月02日 12:08:28   投稿:hebedich  
Foreach-object 為cmdlet命令,使用在管道中,對管道結果逐個處理,foreach為遍歷集合的關鍵字。

下面舉兩個例子:

復制代碼 代碼如下:

$array=7..10
foreach ($n in $array)
{
    $n*$n
}
 
#49
#64
#81
#100
 
foreach($file in dir c:\windows)
{
    if($file.Length -gt 1mb)
    {
        $File.Name
    }
}
 
#explorer.exe
#WindowsUpdate.log

這里只為了演示foreach,其實上面的第二個例子可以用Foreach-Object更簡潔。

復制代碼 代碼如下:

PS C:\Powershell> dir C:\Windows | where {$_.length -gt 1mb} |foreach-object {$_.Name}
explorer.exe
WindowsUpdate.log

相關文章

最新評論