首页 > 其他 > 详细

Get-ChildItem参数之 -Exclude,Filter,Recurse应用

时间:2014-09-25 18:01:58      阅读:1985      评论:0      收藏:0      [点我收藏+]

 

1 $p = "D:\PSScript"
2 
3 gci $p -Exclude "UpdateLog" #排除子目录"UpdateLog",但是后面不能接着使用 -Recurse参数,否则-Exclude参数失效
4 gci $p -Exclude "说明.txt" -Recurse #排除文件"说明.txt",可以一起使用 -Recurse参数
5 
6 gci $p -filter "UpdateLog" #只遍历子目录 "UpdateLog" 
7 gci $p -filter "*server*" #遍历包含关键字 server 的目录
8 gci $p -filter "*server*" -Recurse  # -Recurse参数不生效

 

1  #删除目录下所有文件,保留目录结构,其中除去UpdateLog子目录,除去“说明.txt”文件
2 gci $p -Exclude "UpdateLog" |% { gci $_.FullName -Exclude "说明.txt" -Recurse | ? {!$_.PSIsContainer } | Remove-Item -Force }

 

Get-ChildItem参数之 -Exclude,Filter,Recurse应用

原文:http://www.cnblogs.com/dreamer-fish/p/3993124.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!