共用方式為


Get-ChildItem

取得一或多個指定位置中的項目和子項目。

語法

Get-ChildItem
   [[-Path] <string[]>]
   [[-Filter] <string>]
   [-Include <string[]>]
   [-Exclude <string[]>]
   [-Recurse]
   [-Depth <uint>]
   [-Force]
   [-Name]
   [<CommonParameters>]
Get-ChildItem
   [[-Filter] <string>]
   -LiteralPath <string[]>
   [-Include <string[]>]
   [-Exclude <string[]>]
   [-Recurse]
   [-Depth <uint>]
   [-Force]
   [-Name]
   [<CommonParameters>]
Get-ChildItem
   [[-Path] <string[]>]
   [[-Filter] <string>]
   [-Include <string[]>]
   [-Exclude <string[]>]
   [-Recurse]
   [-Depth <uint>]
   [-Force]
   [-Name]
   [-CodeSigningCert]
   [-DocumentEncryptionCert]
   [-SSLServerAuthentication]
   [-DnsName <string>]
   [-Eku <string[]>]
   [-ExpiringInDays <int>]
   [<CommonParameters>]
Get-ChildItem
   [[-Filter] <string>]
   -LiteralPath <string[]>
   [-Include <string[]>]
   [-Exclude <string[]>]
   [-Recurse]
   [-Depth <uint>]
   [-Force]
   [-Name]
   [-CodeSigningCert]
   [-DocumentEncryptionCert]
   [-SSLServerAuthentication]
   [-DnsName <string>]
   [-Eku <string[]>]
   [-ExpiringInDays <int>]
   [<CommonParameters>]
Get-ChildItem
   [[-Path] <string[]>]
   [[-Filter] <string>]
   [-Include <string[]>]
   [-Exclude <string[]>]
   [-Recurse]
   [-Depth <uint>]
   [-Force]
   [-Name]
   [-Attributes <FlagsExpression[FileAttributes]>]
   [-FollowSymlink]
   [-Directory]
   [-File]
   [-Hidden]
   [-ReadOnly]
   [-System]
   [<CommonParameters>]
Get-ChildItem
   [[-Filter] <string>]
   -LiteralPath <string[]>
   [-Include <string[]>]
   [-Exclude <string[]>]
   [-Recurse]
   [-Depth <uint>]
   [-Force]
   [-Name]
   [-Attributes <FlagsExpression[FileAttributes]>]
   [-FollowSymlink]
   [-Directory]
   [-File]
   [-Hidden]
   [-ReadOnly]
   [-System]
   [<CommonParameters>]

Description

Get-ChildItem cmdlet 會取得一或多個指定位置中的項目。 如果項目是容器,它會取得容器內的項目,稱為子項目。 您可以使用 Recurse 參數來取得所有子容器中的專案,並使用 Depth 參數來限制遞歸層級的數目。

Get-ChildItem 不會顯示空的目錄。 當 Get-ChildItem 命令包含 DepthRecurse 參數時,輸出中不會包含空白目錄。

位置會公開給 PowerShell 提供者 Get-ChildItem。 位置可以是文件系統目錄、登錄區或證書存儲。 某些參數僅適用於特定提供者。 如需詳細資訊,請參閱 about_Providers

範例

範例 1:從檔案系統目錄取得子項目

這個範例會從文件系統目錄取得子項目。 會顯示檔案名和子目錄名稱。 對於空的目錄,命令不會返回任何輸出,並會回到 PowerShell 提示字元。

Get-ChildItem Cmdlet 會使用 Path 參數來指定目錄 C:\TestGet-ChildItem 會在 PowerShell 控制台中顯示檔案和目錄。

Get-ChildItem -Path C:\Test

Directory: C:\Test

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2/15/2019     08:29                Logs
-a----        2/13/2019     08:55             26 anotherfile.txt
-a----        2/12/2019     15:40         118014 Command.txt
-a----         2/1/2019     08:43            183 CreateTestFile.ps1
-ar---        2/12/2019     14:31             27 ReadOnlyFile.txt

根據預設,Get-ChildItem 會列出模式(屬性)、LastWriteTime、檔案大小(長度),以及專案的 NameMode 屬性中的字母可以解譯如下:

  • l (連結)
  • d (目錄)
  • a (封存)
  • r (唯讀)
  • h (隱藏)
  • s(系統)

如需模式旗標的詳細資訊,請參閱 about_Filesystem_Provider

範例 2:取得目錄中的子項目名稱

此範例只會列出目錄中的項目名稱。

Get-ChildItem Cmdlet 會使用 Path 參數來指定目錄 C:\TestName 參數只會從指定的路徑傳回檔案或目錄名稱。 傳回的名稱取決於 Path 參數的值。

Get-ChildItem -Path C:\Test -Name

Logs
anotherfile.txt
Command.txt
CreateTestFile.ps1
ReadOnlyFile.txt

範例 3:獲取目前目錄和子目錄中的子項目

此範例會顯示位於目前目錄及其子目錄中的 .txt 檔案。

Get-ChildItem -Path .\*.txt -Recurse -Force

Directory: C:\Test\Logs\Adirectory

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/12/2019     16:16             20 Afile4.txt
-a-h--        2/12/2019     15:52             22 hiddenfile.txt
-a----        2/13/2019     13:26             20 LogFile4.txt

    Directory: C:\Test\Logs\Backup

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/12/2019     16:16             20 ATextFile.txt
-a----        2/12/2019     15:50             20 LogFile3.txt

    Directory: C:\Test\Logs

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/12/2019     16:16             20 Afile.txt
-a-h--        2/12/2019     15:52             22 hiddenfile.txt
-a----        2/13/2019     13:26             20 LogFile1.txt

    Directory: C:\Test

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/13/2019     08:55             26 anotherfile.txt
-a----        2/12/2019     15:40         118014 Command.txt
-a-h--        2/12/2019     15:52             22 hiddenfile.txt
-ar---        2/12/2019     14:31             27 ReadOnlyFile.txt

Get-ChildItem Cmdlet 會使用 Path 參數來指定 C:\Test\*.txtPath 使用星號 (*) 通配符來指定擴展名為 .txt的所有檔案。 Recurse 參數會搜尋 Path 目錄及其子目錄,如 Directory: 標題中所示。 Force 參數會顯示隱藏的檔案,例如具有 hiddenfile.txt模式的

範例 4:使用 Include 參數取得子項目

在此範例中,Get-ChildItem 會使用 Include 參數,從 Path 參數所指定的目錄中尋找特定專案。

# When using the -Include parameter, if you don't include an asterisk in the path
# the command returns no output.
Get-ChildItem -Path C:\Test\ -Include *.txt



Get-ChildItem -Path C:\Test\* -Include *.txt

Directory: C:\Test

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/13/2019     08:55             26 anotherfile.txt
-a----        2/12/2019     15:40         118014 Command.txt
-ar---        2/12/2019     14:31             27 ReadOnlyFile.txt

Get-ChildItem Cmdlet 會使用 Path 參數來指定目錄 C:\TestPath 參數包含尾端星號 (*) 通配符,以指定目錄的內容。 Include 參數會使用星號 (*) 通配符來指定擴展名為 .txt的所有檔案。

使用 Include 參數時,Path 參數需要尾端星號 (*) 通配符來指定目錄的內容。 例如,-Path C:\Test\*

  • 如果將 Recurse 參數新增至命令中,則在 * 參數中的尾端星號()是可選的。 Recurse 參數會從 Path 目錄及其子目錄中取得項目。 例如,-Path C:\Test\ -Recurse -Include *.txt
  • 如果尾端星號 (*) 未包含在 Path 參數中,則命令不會傳回任何輸出並返回 PowerShell 提示字元。 例如,-Path C:\Test\

範例 5:使用 Exclude 參數取得子項目

此範例的輸出會顯示目錄 C:\Test\Logs的內容。 輸出用作其他命令的參考,這些命令使用 ExcludeRecurse 參數。

Get-ChildItem -Path C:\Test\Logs

Directory: C:\Test\Logs

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2/15/2019     13:21                Adirectory
d-----        2/15/2019     08:28                AnEmptyDirectory
d-----        2/15/2019     13:21                Backup
-a----        2/12/2019     16:16             20 Afile.txt
-a----        2/13/2019     13:26             20 LogFile1.txt
-a----        2/12/2019     16:24             23 systemlog1.log

Get-ChildItem -Path C:\Test\Logs\* -Exclude A*

Directory: C:\Test\Logs

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2/15/2019     13:21                Backup
-a----        2/13/2019     13:26             20 LogFile1.txt
-a----        2/12/2019     16:24             23 systemlog1.log

Get-ChildItem Cmdlet 會使用 Path 參數來指定目錄 C:\Test\LogsExclude 參數會使用星號 (*) 通配符來指定以 Aa 開頭的任何檔案或目錄,都會從輸出中排除。

使用 Exclude 參數時,* 參數中的尾端星號()是可選的。 例如,-Path C:\Test\Logs-Path C:\Test\Logs\*

  • 如果尾端星號 (*) 未包含在 Path 參數中,則會顯示 Path 參數的內容。 例外狀況是符合 排除 參數值的檔名或子目錄名稱。
  • 如果尾端星號 (*) 包含在 Path 參數中,命令就會遞歸至 Path 參數的子目錄。 例外狀況是符合 排除 參數值的檔名或子目錄名稱。
  • 如果 Recurse 參數新增至命令,則遞歸輸出會與 Path 參數是否包含尾端星號 (*) 相同。

範例 6:從登錄區取得登錄機碼

本範例會從 HKEY_LOCAL_MACHINE\HARDWARE取得所有登錄機碼。

Get-ChildItem 會使用 Path 參數來指定登錄機碼 HKLM:\HARDWARE。 Hive 的路徑和最上層的登錄機碼會顯示在PowerShell控制台中。

如需詳細資訊,請參閱 about_Registry_Provider

Get-ChildItem -Path HKLM:\HARDWARE

Hive: HKEY_LOCAL_MACHINE\HARDWARE

Name             Property
----             --------
ACPI
DESCRIPTION
DEVICEMAP
RESOURCEMAP
UEFI

Get-ChildItem -Path HKLM:\HARDWARE -Exclude D*

Hive: HKEY_LOCAL_MACHINE\HARDWARE

Name                           Property
----                           --------
ACPI
RESOURCEMAP

第一個命令會顯示 HKLM:\HARDWARE 登錄機碼的內容。 Exclude 參數會告知 Get-ChildItem 不要傳回以 D*開頭的任何子機碼。 目前,Exclude 參數僅適用於子機碼,不適用於項目屬性。

範例 7:取得所有程式簽章憑證

此範例會取得 PowerShell Cert: 磁碟驅動器中具有程式碼簽署權限的每個憑證。

Get-ChildItem Cmdlet 會使用 Path 參數來指定具有 Cert: 磁碟驅動器的憑證提供者。 Recurse 參數會搜尋 路徑 所指定的目錄及其子目錄。 CodeSigningCert 參數只會取得具有程式代碼簽署授權單位的憑證。

Get-ChildItem -Path Cert:\* -Recurse -CodeSigningCert

如需憑證提供者和 Cert: 磁碟驅動器的詳細資訊,請參閱 about_Certificate_Provider

範例 8:使用 Depth 參數取得項目

此範例列出目錄及其子目錄中的項目。 Depth 參數會決定要包含在遞歸中的子目錄層級數目。 空白目錄會從輸出中排除。

Get-ChildItem -Path C:\Parent -Depth 2

Directory: C:\Parent

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2/14/2019     10:24                SubDir_Level1
-a----        2/13/2019     08:55             26 file.txt

    Directory: C:\Parent\SubDir_Level1

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2/14/2019     10:24                SubDir_Level2
-a----        2/13/2019     08:55             26 file.txt

    Directory: C:\Parent\SubDir_Level1\SubDir_Level2

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2/14/2019     10:22                SubDir_Level3
-a----        2/13/2019     08:55             26 file.txt

Get-ChildItem Cmdlet 會使用 Path 參數來指定 C:\ParentDepth 參數會指定兩個遞歸層級。 Get-ChildItem 會顯示 Path 參數所指定的目錄內容,以及子目錄的兩個層級。

範例 9:取得硬式鏈接資訊

在 PowerShell 6.2 中,已新增替代檢視以取得硬式連結資訊。

Get-ChildItem -Path C:\PathContainingHardLink | Format-Table -View childrenWithHardLink

範例 10:非 Windows 作業系統的輸出

在 Unix 系統上的 PowerShell 7.1 中,Get-ChildItem 提供類似 Unix 的輸出:

PS> Get-ChildItem /etc/r*

Directory: /etc

UnixMode   User Group    LastWriteTime Size Name
--------   ---- -----    ------------- ---- ----
drwxr-xr-x root wheel  9/30/2019 19:19  128 racoon
-rw-r--r-- root wheel  9/26/2019 18:20 1560 rc.common
-rw-r--r-- root wheel  7/31/2017 17:30 1560 rc.common~previous
-rw-r--r-- root wheel  9/27/2019 20:34 5264 rc.netboot
lrwxr-xr-x root wheel  11/8/2019 15:35   22 resolv.conf -> /private/var/run/resolv.conf
-rw-r--r-- root wheel 10/23/2019 17:41    0 rmtab
-rw-r--r-- root wheel 10/23/2019 17:41 1735 rpc
-rw-r--r-- root wheel  7/25/2017 18:37 1735 rpc~previous
-rw-r--r-- root wheel 10/23/2019 18:42  891 rtadvd.conf
-rw-r--r-- root wheel  8/24/2017 21:54  891 rtadvd.conf~previous

現在屬於輸出一部分的新屬性如下:

  • UnixMode 是 Unix 系統上所代表的檔案許可權
  • 使用者 是檔案擁有者
  • 群組 是群組擁有者
  • Size 是 Unix 系統上所代表的檔案或目錄大小

備註

此功能已從實驗性移至 PowerShell 7.1 中的主流。

範例 11:取得連接點的連結目標

Windows 命令殼層中的 dir 命令會顯示檔案系統連接點的目標位置。 在 PowerShell 中,此資訊可從 傳回之文件系統物件的 Get-ChildItem 屬性取得,並顯示在默認輸出中。

PS D:\> New-Item -ItemType Junction -Name tmp -Target $env:TEMP
PS D:\> Get-ChildItem | Select-Object name, LinkTarget

Name     LinkTarget
----     ----------
tmp      C:\Users\user1\AppData\Local\Temp

PS D:\> Get-ChildItem

    Directory: D:\

Mode          LastWriteTime    Length Name
----          -------------    ------ ----
l----   12/16/2021  9:29 AM           tmp -> C:\Users\user1\AppData\Local\Temp

範例 12:取得 AppX 重新分析點的連結目標

此範例會嘗試取得 AppX 重新解析點的目標資訊。 Microsoft市集應用程式會在使用者的 AppData 目錄中建立 AppX 重新分析點。

Get-ChildItem ~\AppData\Local\Microsoft\WindowsApps\MicrosoftEdge.exe |
    Select-Object Mode, LinkTarget, LinkType, Name

Mode  LinkTarget LinkType Name
----  ---------- -------- ----
la---                     MicrosoftEdge.exe

目前,Windows 尚未提供一種方式來取得 AppX 重新分析點的目標資訊。 filesystem 物件的 LinkTargetLinkType 属性是空的。

參數

-Attributes

備註

此參數僅適用於 FileSystem 提供者。

取得具有指定屬性的檔案和資料夾。 此參數支援所有屬性,並可讓您指定屬性的複雜組合。

例如,若要取得加密或壓縮的非系統檔案(非目錄),請輸入:

Get-ChildItem -Attributes !Directory+!System+Encrypted, !Directory+!System+Compressed

若要尋找具有常用屬性的檔案和資料夾,請使用 Attributes 參數。 或者,參數 DirectoryFileHiddenReadOnlySystem

Attributes 參數支援下列屬性:

  • 封存
  • 壓縮
  • 裝置
  • 目錄
  • 加密
  • 隱藏
  • IntegrityStream
  • 一般
  • NoScrubData
  • 未索引內容
  • 離線
  • 唯讀
  • ReparsePoint
  • 稀疏文件
  • 系統
  • 暫存

如需這些屬性的描述,請參閱 FileAttributes 列舉。

若要合併屬性,請使用下列運算子:

  • ! (非)
  • + (和)
  • , (OR)

請勿在運算子與其屬性之間使用空格。 逗號後面允許有空格。

針對一般屬性,請使用下列縮寫:

  • D (目錄)
  • H (隱藏)
  • R(唯讀)
  • S (系統)
類型:FlagsExpression<T>[FileAttributes]
接受的值:Archive, Compressed, Device, Directory, Encrypted, Hidden, IntegrityStream, Normal, NoScrubData, NotContentIndexed, Offline, ReadOnly, ReparsePoint, SparseFile, System, Temporary
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-CodeSigningCert

備註

此參數僅適用於 憑證 提供者。

若要取得其 Code Signing 屬性值中具有 的憑證清單,請使用 CodeSigningCert 參數。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Depth

此參數已在 PowerShell 5.0 中新增,可讓您控制遞歸深度。 根據預設,Get-ChildItem 會顯示父目錄的內容。 Depth 參數會決定遞歸中包含的子目錄層級數目,並顯示內容。

例如,-Depth 2 包含 Path 參數的目錄、子目錄的第一層,以及子目錄的第二層。 根據預設,輸出中會包含目錄名稱和檔名。

備註

在 PowerShell 或 cmd.exe的 Windows 電腦上,您可以使用 tree.com 命令來顯示目錄結構的圖形檢視。

類型:UInt32
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Directory

備註

此參數僅適用於 FileSystem 提供者。

若要取得目錄清單,請使用 Directory 參數或 Attributes 參數搭配 Directory 屬性。 您可以將 Recurse 參數與 Directory搭配使用。

類型:SwitchParameter
別名:ad
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DnsName

備註

此參數僅適用於 憑證 提供者。

指定網域名稱或名稱模式,與 Cmdlet 取得的憑證之 DNSNameList 屬性相符。 這個參數的值可以是 UnicodeASCII。 Punycode 值會轉換成 Unicode。 允許使用通配符(*)。

此參數已在PowerShell 7.1中重新引入

類型:DnsNameRepresentation
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:True

-DocumentEncryptionCert

備註

此參數僅適用於 憑證 提供者。

若要取得其 Document Encryption 屬性值中具有 的憑證清單,請使用 DocumentEncryptionCert 參數。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Eku

備註

此參數僅適用於 憑證 提供者。

指定文字或文字模式,以符合 Cmdlet 所取得憑證的 EnhancedKeyUsageList 屬性。 允許使用通配符(*)。 EnhancedKeyUsageList 屬性包含 EKU 的友好名稱和 OID 欄位。

此參數已在PowerShell 7.1中重新引入

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:True

-Exclude

指定一個或多個字串模式陣列來進行比對,當 Cmdlet 取得子專案時。 輸出中會排除任何相符的專案。 輸入路徑元素或模式,例如 *.txtA*。 可以接受通配符。

* 參數中的尾端星號 () 是選擇性的。 例如,-Path C:\Test\Logs-Path C:\Test\Logs\*。 如果包含尾端星號(*),命令就會遞歸至 Path 參數的子目錄。 如果沒有星號 (*),則會顯示 Path 參數的內容。 範例 5 和附註一節包含更多詳細數據。

IncludeExclude 參數可以一起使用。 不過,排除項目會在包含項目之後套用,這可能會影響最終輸出。

類型:String[]
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:True

-ExpiringInDays

備註

此參數僅適用於 憑證 提供者。

指定 Cmdlet 應該只傳回在指定天數內或之前到期的憑證。 值為零 (0) 會取得已過期的憑證。

此參數已在PowerShell 7.1中重新引入

類型:Int32
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-File

備註

此參數僅適用於 FileSystem 提供者。

若要取得檔案清單,請使用 File 參數。 您可以使用 Recurse 參數搭配 File

類型:SwitchParameter
別名:af
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Filter

指定篩選條件,以限定 Path 參數。 FileSystem 提供者是唯一支持篩選的已安裝 PowerShell 提供者。 篩選比其他參數更有效率。 提供者會在 Cmdlet 獲取物件時套用篩選,而不是在擷取物件之後讓 PowerShell 進行篩選。 篩選字串會傳遞至 .NET API 以列舉檔案。 API 僅支援 *? 通配符。

類型:String
Position:1
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:True

備註

此參數僅適用於 FileSystem 提供者。

根據預設,Get-ChildItem Cmdlet 會顯示遞歸期間找到之目錄的符號連結,但不會遞歸至目錄。 使用 FollowSymlink 參數來搜尋以這些符號連結為目標的目錄。 FollowSymlink 是動態參數,且僅支援 FileSystem 提供者。

此參數是在 PowerShell 6.0 中引進的。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Force

允許 Cmdlet 取得使用者無法存取的項目,例如隱藏或系統檔案。 Force 參數不會覆寫安全性限制。 實作會因提供者而異。 如需詳細資訊,請參閱 about_Providers

類型:SwitchParameter
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

-Hidden

備註

此參數僅適用於 FileSystem 提供者。

若要取得僅隱藏的項目,請使用 Hidden 參數或將 Attributes 參數與 Hidden 屬性搭配使用。 根據預設,Get-ChildItem 不會顯示隱藏項目。 使用 Force 參數來取得隱藏的項目。

類型:SwitchParameter
別名:ah, h
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Include

指定一個或多個字串模式陣列來進行比對,當 Cmdlet 取得子專案時。 輸出中包含任何相符的項目。 輸入路徑元素或模式,例如 "*.txt"。 允許使用通配符。 只有當命令包含項目的內容,例如 時,C:\Windows\* 參數才有效,其中通配符會指定 C:\Windows 目錄的內容。

IncludeExclude 參數可以一起使用。 不過,排除項目會在包含項目之後套用,這可能會影響最終輸出。

類型:String[]
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:True

-LiteralPath

指定一或多個位置的路徑。 LiteralPath 的值會完全按照其原樣使用。 不會將任何字元解譯為通配符。 如果路徑包含逸出字元,請以單引弧括住它。 單引號會告知PowerShell不要將任何字元解譯為逸出序列。

如需詳細資訊,請參閱 about_Quoting_Rules

類型:String[]
別名:PSPath, LP
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-Name

只取得位置中項目的名稱。 輸出是一個字串物件,可以經由管線傳送至其他命令。 傳回的名稱取決於 Path 參數的值。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Path

指定一或多個位置的路徑。 接受通配符。 預設位置是目前目錄 (.)。

類型:String[]
Position:0
預設值:Current directory
必要:False
接受管線輸入:True
接受萬用字元:True

-ReadOnly

備註

此參數僅適用於 FileSystem 提供者。

若要取得唯讀項目,請使用 ReadOnly 參數或 Attributes 參數 ReadOnly 屬性。

類型:SwitchParameter
別名:ar
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Recurse

取得指定位置及其所有子項目中的項目。

類型:SwitchParameter
別名:s, r
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

-SSLServerAuthentication

備註

此參數僅適用於 憑證 提供者。

若要取得其 Server Authentication 屬性值中具有 的憑證清單,請使用 SSLServerAuthentication 參數。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-System

備註

此參數僅適用於 FileSystem 提供者。

只取得系統檔案和目錄。 若要只取得系統檔案和資料夾,請使用 System 參數或 Attributes 參數 System 屬性。

類型:SwitchParameter
別名:as
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

String

您可以使用管線傳送包含此 Cmdlet 路徑的字串。

輸出

AliasInfo

Cmdlet 會在存取 Alias: 磁碟驅動器時輸出此類型。

X509StoreLocation

X509Store

X509Certificate2

Cmdlet 會在存取 Cert: 磁碟驅動器時輸出這些類型。

DictionaryEntry

Cmdlet 會在存取 Env: 磁碟驅動器時輸出此類型。

DirectoryInfo

FileInfo

Cmdlet 會在存取檔案系統磁碟驅動器時輸出這些類型。

FunctionInfo

FilterInfo

Cmdlet 會在存取 Function: 磁碟驅動器時輸出這些類型。

RegistryKey

Cmdlet 會在存取登錄磁碟驅動器時輸出此類型。

PSVariable

Cmdlet 會在存取 Variable: 磁碟驅動器時輸出此類型。

WSManConfigContainerElement

WSManConfigLeafElement

Cmdlet 會在存取 WSMan: 磁碟驅動器時輸出這些類型。

String

當您使用 Name 參數時,這個 Cmdlet 會以字串的形式傳回物件名稱。

備註

PowerShell 包含下列 Get-ChildItem別名:

  • 所有平臺:
    • dirgci
  • 窗戶:
    • ls

預設情況下,Get-ChildItem 不會取得隱藏的項目。 若要取得隱藏的專案,請使用 Force 參數。

Get-ChildItem Cmdlet 的設計目的是要處理任何提供者所公開的數據。 若要列出工作階段中可用的提供者,請輸入 Get-PSProvider。 如需詳細資訊,請參閱 about_Providers