如何在PowerShell中仅获取文件夹而不获取Get-ChildItem中的文件?
要仅获取不包括文件的文件夹,我们需要将–Attribute参数与Directory属性一起使用。
命令
Get-ChildItem D:\Temp\ -Attributes Directory
输出结果
Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 13-12-2019 09:52 GPO_backup d----- 24-11-2018 11:31 LGPO
同样,您可以组合不同的操作。
要获取唯一的系统目录,请使用以下命令。
Get-ChildItem D:\Temp\ -Attributes Directory –System -Recurse
获取隐藏的系统目录。
Get-ChildItem D:\Temp\ -Attributes Directory -Recurse –System -Hidden
获取只读的系统目录。
Get-ChildItem D:\Temp\ -Attributes Directory -Recurse –System -Readonly
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短