Get-ChildItem

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

Syntax

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

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

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

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

範例

範例 1:從文件系統目錄取得子專案

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

Cmdlet Get-ChildItem 會使用 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 ,會列出模式 (Attributes)、 LastWriteTime、檔案大小(Length),以及 項目的名稱 。 Mode 屬性中的字母可以解譯如下:

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

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

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

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

Cmdlet Get-ChildItem 會使用 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

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

範例 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

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

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

  • 如果 Recurse 參數新增至命令,Path 參數中的尾端星號 (*) 是選擇性的。 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

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

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

  • 如果 Path 參數中未包含尾端星號 (*) ,則會顯示 Path 參數的內容。 例外狀況是符合 Exclude 參數值的檔名或子目錄名稱。
  • 如果 Path 參數中包含尾端星號 (*) ,命令就會遞歸至 Path 參數的子目錄。 例外狀況是符合 Exclude 參數值的檔名或子目錄名稱。
  • 如果 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:\HARDWAREExclude 參數會告知Get-ChildItem不要傳回以 開頭D*的任何子機碼。 目前, Exclude 參數僅適用於子機碼,不適用於項目屬性。

範例 7:取得具有程式代碼簽署授權單位的所有憑證

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

Cmdlet Get-ChildItem 會使用 Path 參數來指定具有磁碟驅動器的 Cert: 憑證提供者。 Recurse 參數會搜尋 Path 及其子目錄所指定的目錄。 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

Cmdlet Get-ChildItem 會使用 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:取得連接點的鏈接目標

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

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 Store 應用程式會在使用者的 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重新分析點的目標資訊。 文件系統物件的LinkTargetLinkType屬性是空的。

參數

-Attributes

注意

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

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

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

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

若要尋找具有常用屬性的檔案和資料夾,請使用 Attributes 參數。 或者,參數 Directory、File、Hidden、ReadOnly 和 System。

Attributes 參數支援下列屬性:

  • 封存
  • Compressed
  • 裝置
  • 目錄
  • 已加密
  • Hidden
  • IntegrityStream
  • Normal
  • NoScrubData
  • NotContentIndexed
  • 離線
  • ReadOnly
  • ReparsePoint
  • 疏鬆File
  • 系統
  • 臨時

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

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

  • ! (NOT)
  • + (AND)
  • , (OR)

請勿在運算子與其屬性之間使用空格。 逗號後面會接受空格。

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

  • D (目錄)
  • H (隱藏)
  • R (唯讀)
  • S (系統)
Type:FlagsExpression<T>[FileAttributes]
Accepted values:Archive, Compressed, Device, Directory, Encrypted, Hidden, IntegrityStream, Normal, NoScrubData, NotContentIndexed, Offline, ReadOnly, ReparsePoint, SparseFile, System, Temporary
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CodeSigningCert

注意

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

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Depth

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

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

注意

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

Type:UInt32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Directory

注意

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

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

Type:SwitchParameter
Aliases:ad
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DnsName

注意

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

指定功能變數名稱或名稱模式,以符合 Cmdlet 所取得憑證的 DNSNameList 屬性。 這個參數的值可以是 UnicodeASCII。 Punycode 值會轉換成 Unicode。 允許通配符 (*) 。

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

Type:DnsNameRepresentation
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-DocumentEncryptionCert

注意

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

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Eku

注意

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

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

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-Exclude

指定要比對的一或多個字串模式陣列,因為 Cmdlet 會取得子專案。 輸出中會排除任何相符的專案。 輸入路徑專案或模式,例如 *.txtA*。 接受通配符。

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

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

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-ExpiringInDays

注意

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

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

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

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-File

注意

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

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

Type:SwitchParameter
Aliases:af
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Filter

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

Type:String
Position:1
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

注意

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

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

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

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

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Hidden

注意

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

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

Type:SwitchParameter
Aliases:ah, h
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Include

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

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

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-LiteralPath

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

如需詳細資訊,請參閱 about_Quoting_Rules

Type:String[]
Aliases:PSPath, LP
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Name

只取得位置中項目的名稱。 輸出是字串物件,可將管線向下傳送至其他命令。 傳回的名稱會相對於Path參數的值

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Path

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

Type:String[]
Position:0
Default value:Current directory
Required:False
Accept pipeline input:True
Accept wildcard characters:True

-ReadOnly

注意

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

若要只取得只讀專案,請使用 ReadOnly 參數或 Attributes 參數 ReadOnly 屬性。

Type:SwitchParameter
Aliases:ar
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Recurse

取得指定位置和所有位置子專案中的專案。

Type:SwitchParameter
Aliases:s
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SSLServerAuthentication

注意

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

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-System

注意

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

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

Type:SwitchParameter
Aliases:as
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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別名:

  • 所有平臺:
    • dir, gci
  • Windows:
    • ls

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

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