如何在PowerShell中使用Get-ChildItem获取系统文件?

How to get the system files using the Get-ChildItem in PowerShell?

系统文件是操作系统文件,默认情况下,使用Get-ChildItem不可见。 要获取系统文件,您需要使用–System参数。

例如,下面的命令将为您提供C:WindowsSystem32下的系统文件和文件夹。

1
PS C:\WINDOWS\system32> Get-ChildItem -System

输出量

1
2
3
4
5
6
7
8
9
10
Directory: C:\WINDOWS\system32
Mode        LastWriteTime     Length Name
----        -------------     ------ ----
d---s-    25-12-2019   01:14        AppV
d---s-    19-03-2019   10:22        Configuration
d---s-    23-12-2019   02:45        DiagSvcs
d---s-    19-03-2019   11:50        dsc
d---s-    19-03-2019   11:50        F12
d---s-    19-03-2019   10:23        Nui
d---s-    19-03-2019   10:23        UNP

命令

您还可以组合多个参数。 例如,要获取只读的系统文件,请使用命令,

1
PS C:\WINDOWS\system32> Get-ChildItem –System –ReadOnly -Recurse

输出量

1
2
3
4
5
Directory: C:\WINDOWS\system32
estore
Mode        LastWriteTime     Length Name
----        -------------     ------ ----
-ar-s-    24-12-2019   23:40       76 MachineGuid.txt

命令

获取隐藏的系统文件。

1
PS C:\WINDOWS\system32> Get-ChildItem –System –Hidden -Recurse

输出量

1
2
3
4
5
6
7
8
9
10
Directory: C:\WINDOWS\system32\SMI\Store\Machine
Mode        LastWriteTime     Length Name
----        -------------     ------ ----
-a-hs-    19-03-2019   10:07       0 SCHEMA.DAT.LOG1
-a-hs-    19-03-2019   10:07      8192 SCHEMA.DAT.LOG2
-a-hs-    25-12-2019   01:16     65536 SCHEMA.DAT{fd9a35e3-49fe-11e9-aa2c-248a07783950}.TM.blf
-a-hs-    25-12-2019   01:16     524288 SCHEMA.DAT{fd9a35e3-49fe-11e9-aa2c-248a07783950}.TMContainer0000000000
                        0000000001.regtrans-ms
-a-hs-    19-03-2019   13:11     524288 SCHEMA.DAT{fd9a35e3-49fe-11e9-aa2c-248a07783950}.TMContainer0000000000
                        0000000002.regtrans-ms