PowerShell 的 Get-ChildItem cmdlet 可能返回哪些“模式"值? [英] What are the possible 'Mode' values returned by PowerShell's Get-ChildItem cmdlet?
问题描述
当我在目录上运行 PowerShell 的 Get-ChildItem 时(或任何返回文件系统项的 cmdlet),它会显示一个名为 Mode
的列,如下所示:
When I run PowerShell's Get-ChildItem on a directory (or any cmdlet that returns file system items), it shows a column called Mode
, like this:
Directory: C:\MyDirectory
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2/8/2011 10:55 AM Directory1
d---- 2/8/2011 10:54 AM Directory2
d---- 2/8/2011 10:54 AM Directory3
-ar-- 2/8/2011 10:54 AM 454 File1.txt
-ar-- 2/8/2011 10:54 AM 4342 File2.txt
我搜索并搜索了 Google 和我本地的 PowerShell 书籍,但找不到任何关于 Mode
列含义的文档.
I searched and searched Google and my local PowerShell book, but I could not find any documentation on the meaning of the Mode
column.
Mode 列的可能值是什么,每个值的含义是什么?
推荐答案
请注意,您看到的模式只是位域 enum
的字符串表示,它隐藏在属性
属性.您只需将两个字母并排显示即可了解各个字母的含义:
Note that the mode you see is just a string representation of a bitfield enum
that hides in the Attributes
property. You can figure out what the individual letters mean by simply showing both side by side:
PS> gci|select mode,attributes -u
Mode Attributes
---- ----------
d----- Directory
d-r--- ReadOnly, Directory
d----l Directory, ReparsePoint
-a---- Archive
无论如何,完整列表是:
In any case, the full list is:
d - Directory
a - Archive
r - Read-only
h - Hidden
s - System
l - Reparse point, symlink, etc.
这篇关于PowerShell 的 Get-ChildItem cmdlet 可能返回哪些“模式"值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!