如何在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 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短