In PowerShell, the cmdlet that lists the files is Get-childitem and the alias is dir. For example, we use "dir $env: windir" To display the Windows directory files and folders.
Command:
Copy Code code as follows:
Output:
Copy Code code as follows:
Table of Contents: C:\Windows
Mode LastWriteTime Length Name
---- ------------- ------ ----
D----2009/7/14 13:32 addins
D-r-s 2013/6/24 10:48 Assembly
D----2009/7/14 18:31 ZH-CN
...... The folder section above
-A---2009/7/14 9:38 71168 bfsvc.exe
-a--s 2013/7/17 7:42 67584 bootstat.dat
-A---2009/7/14 9:39 10240 write.exe
...... The file section above
Here, let's take a look at the Mode property, which is a total of five characters, representing five properties.
The first character, if "D", indicates that it is a folder, and if "-", it is a file.
The second character, if "A", represents an archive file or folder, that is, the archive property.
The third character, if "R", indicates that the file or folder is a read-only type, that is, read-only.
The fourth character, if "H", indicates that the file or folder is hidden, that is, hidden.
The fifth character, if "s", indicates that the file or folder is a system, that is, systems.
In Windows Explorer, in Folder Options, there is an option to display all files or folders, which opens to show hidden files. There is also an option to display system files and folders, which can be turned on to display system files and folders.
In PowerShell, the dir command does not display hidden files or folders by default, and if you add a "-force" parameter, you can force all files or folders to be displayed. If you want to see only hidden files or folders Further, you can add filter criteria.
Command:
Copy Code code as follows:
PS >get-childitem $env: Windir-force | Where-object {$_. Mode-like ' *h* '}
Output:
Copy Code code as follows:
Table of Contents: C:\Windows
Mode LastWriteTime Length Name
---- ------------- ------ ----
D--HS 2009/7/14 18:44 bitlockerdiscoveryvolumecontents
D--HS 2013/7/15 13:31 Installer
-ARH-2009/7/14 12:54 749 Windowsshell.manifest
Description
This command requires that the files and folders under all $env:windir be exported, and then the object with the hidden attribute "H" is filtered out.
In PowerShell 3.0, you can also use a more straightforward way to display files and files that hide properties.
Command:
Copy Code code as follows:
PS >get-childitem $env: Windir-attributes H
OK, about the display hidden files and folders, small series on the introduction to here, I hope to help you, thank you!