如何在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 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短