码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-09-25 19:27:27      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   使用   for   文件   sp   div   on   

 

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应用

标签:style   blog   color   使用   for   文件   sp   div   on   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!