主页 > 知识库 > Windows Powershell Foreach 循环

Windows Powershell Foreach 循环

热门标签:铁路电话系统 百度竞价排名 地方门户网站 网站排名优化 呼叫中心市场需求 Linux服务器 服务外包 AI电销

下面举两个例子:

复制代码 代码如下:

$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

您可能感兴趣的文章:
  • Windows Powershell IF-ELSEIF-ELSE 语句
  • Windows Powershell Switch 语句
  • Windows Powershell ForEach-Object 循环
  • Windows Powershell Do While 循环
  • Windows Powershell For 循环
  • Windows Powershell Switch 循环

标签:湖南 仙桃 兰州 黄山 衡水 湘潭 崇左 铜川

巨人网络通讯声明:本文标题《Windows Powershell Foreach 循环》,本文关键词  ;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 收缩
    • 微信客服
    • 微信二维码
    • 电话咨询

    • 400-1100-266