如何在 PowerShell 中使用 Get-ChildItem 獲取系統檔案?
系統檔案是作業系統檔案,預設情況下使用 Get-ChildItem 無法看到。要獲取系統檔案,需要使用 -System 引數。
示例
例如,以下命令將在 C:\Windows\System32 下為你提供系統檔案和資料夾。
PS C:\WINDOWS\system32> Get-ChildItem -System
輸出
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
命令
你還可以組合多個引數。例如,要獲取只讀的系統檔案,可以使用命令:
PS C:\WINDOWS\system32> Get-ChildItem –System –ReadOnly -Recurse
輸出
Directory: C:\WINDOWS\system32\restore Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar-s- 24-12-2019 23:40 76 MachineGuid.txt
命令
要獲取隱藏的系統檔案。
PS C:\WINDOWS\system32> Get-ChildItem –System –Hidden -Recurse
輸出
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
廣告