powershell中的find命令
powershell吧
全部回复
仅看楼主
level 9
yuchanbest 楼主
请问powershell中想要检测是否有某项出现的命令是哪一个?
例如batch的命令有 ver|find /i "5" 那么powershell中应该怎样写呢? 是get-childitem吗?
2013年02月27日 13点02分 1
level 7
cmd /c ver|Where-Object{$_ -match "6"}
2013年02月28日 03点02分 2
我是想要判断,比如我用get-process获取了电脑的进程,然后想要判断进程中是否有“notepad.exe”进程,有就输出yes,没有就输出no。那该如何写?
2013年02月28日 05点02分
level 7
if((Get-Process|%{$_.ProcessName}) -contains "notepad"){"yes"}else{"no"}
2013年03月01日 05点03分 3
oh 一时进死胡同了 完全没想过这样 谢谢
2013年03月01日 08点03分
想问一下 关于if((Get-Process|%{$_.ProcessName}) 不太懂中间|%{$_.processname}的写法
2013年03月01日 09点03分
level 7
%是ForEach-Object的简写别名。
意思就是把进程名输出成一个字符串数组[string[]]。
用于contains比较。
2013年03月04日 01点03分 4
谢谢你!
2013年03月06日 08点03分
1