源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Windows Powershell Foreach 循环

  • 时间:2022-11-09 21:27 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Windows Powershell Foreach 循环
下面举两个例子:
[u]复制代码[/u] 代码如下:
$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更简洁。
[u]复制代码[/u] 代码如下:
PS C:\Powershell> dir C:\Windows | where {$_.length -gt 1mb} |foreach-object {$_.Name} explorer.exe WindowsUpdate.log
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部