手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Windows Powershell Foreach 循环
Windows Powershell Foreach 循环
摘要:下面举两个例子:复制代码代码如下:$array=7..10foreach($nin$array){$n*$n}#49#64#81#100fo...

下面举两个例子:

复制代码 代码如下:

$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 Foreach 循环】相关文章:

类似rpm包管理器的Windows Installer PowerShell Module简介

Windows Powershell分析和比较管道结果

Windows Powershell排序和分组管道结果

Windows Powershell创建对象

Windows Powershell Switch 语句

Windows Powershell 变量的作用域

Windows Powershell方法(对象能做什么)

Windows Powershell对象转换成文本

Windows Powershell 进行数学运算

Windows Powershell 执行文件和脚本

精品推荐
分类导航