diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md index 98e1f5473195..ec54d1e0275b 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md @@ -1,7 +1,7 @@ --- description: FileSystem Locale: en-US -ms.date: 01/10/2023 +ms.date: 06/14/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_filesystem_provider?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: about FileSystem Provider @@ -67,9 +67,27 @@ instances of the [System.IO.DirectoryInfo][02] class. The PowerShell Extended Type System adds extra properties to these object types to provide additional information. Some information is platform specific. For example, the possible values of the **LinkType** property depend on the -platform and filesystem being used. On Windows, NTFS supports `HardLink`, -`SymLink`, and `Junction` values for **LinkType**. Linux and macOS filesystems -only support `HardLink` and `SymLink`. +platform and filesystem being used. Linux and macOS filesystems support +`HardLink` and `SymLink`. Windows NTFS supports `HardLink`, `SymLink`, +`Junction`, and several other values for **LinkType**. + +When you use `Get-Item` or `Get-ChildItem` to information about a linked item, +the **Mode** property contains an `l` to indicate that the item is a link. The +**LinkType** property contains the type of link. + +`AppExecLink` links are created when you install an application from the +Microsoft Store. For `AppExecLink` links, Windows doesn't provide values for +the **LinkType** or **LinkTarget** properties. + +```powershell +Get-Item ~\AppData\Local\Microsoft\WindowsApps\winget.exe + + Directory: C:\Users\user1\AppData\Local\Microsoft\WindowsApps + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +-a---l 6/8/2023 12:20 PM 0 winget.exe +``` ## Navigating the FileSystem drives diff --git a/reference/5.1/Microsoft.PowerShell.Management/Get-ChildItem.md b/reference/5.1/Microsoft.PowerShell.Management/Get-ChildItem.md index 26584ab515ee..e86ff65f08fe 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Get-ChildItem.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Get-ChildItem.md @@ -29,11 +29,48 @@ Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] [- ``` Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] - [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] [-UseTransaction] - [-Attributes ] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [] +``` + +### Items (Default) - Certificate provider + +``` +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-CodeSigningCert] [-DocumentEncryptionCert] [-SSLServerAuthentication] + [-DnsName ] [-Eku ] [-ExpiringInDays ] + [] +``` + +### LiteralItems - Certificate provider + +``` +Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-CodeSigningCert] [-DocumentEncryptionCert] [-SSLServerAuthentication] + [-DnsName ] [-Eku ] [-ExpiringInDays ] [] ``` +### Items (Default) - Filesystem provider + +``` +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-Attributes ] [-FollowSymlink] [-Directory] + [-File] [-Hidden] [-ReadOnly] [-System] [] +``` + +### LiteralItems - FileSystem provider + +``` +Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-Attributes ] [-FollowSymlink] [-Directory] + [-File] [-Hidden] [-ReadOnly] [-System] [] +``` + ## DESCRIPTION The `Get-ChildItem` cmdlet gets the items in one or more specified locations. If the item is a @@ -45,7 +82,8 @@ of levels to recurse. **Depth** or **Recurse** parameters, empty directories aren't included in the output. Locations are exposed to `Get-ChildItem` by PowerShell providers. A location can be a file system -directory, registry hive, or a certificate store. For more information, see +directory, registry hive, or a certificate store. Some parameters are only available for a specific +provider. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). ## EXAMPLES @@ -84,7 +122,7 @@ as follows: - `a` (archive) - `r` (read-only) - `h` (hidden) -- `s` (system). +- `s` (system) For more information about the mode flags, see [about_Filesystem_Provider](../microsoft.powershell.core/about/about_filesystem_provider.md#attributes-flagsexpression). @@ -111,7 +149,7 @@ ReadOnlyFile.txt ### Example 3: Get child items in the current directory and subdirectories -This example displays **.txt** files that are located in the current directory and its +This example displays `.txt` files that are located in the current directory and its subdirectories. ```powershell @@ -187,10 +225,10 @@ Mode LastWriteTime Length Name -ar--- 2/12/2019 14:31 27 ReadOnlyFile.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory **C:\Test**. The +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test`. The **Path** parameter includes a trailing asterisk (`*`) wildcard to specify the directory's contents. The **Include** parameter uses an asterisk (`*`) wildcard to specify all files with the file name -extension **.txt**. +extension `.txt`. When the **Include** parameter is used, the **Path** parameter needs a trailing asterisk (`*`) wildcard to specify the directory's contents. For example, `-Path C:\Test\*`. @@ -203,7 +241,7 @@ wildcard to specify the directory's contents. For example, `-Path C:\Test\*`. ### Example 5: Get child items using the Exclude parameter -The example's output shows the contents of the directory **C:\Test\Logs**. The output is a reference +The example's output shows the contents of the directory `C:\Test\Logs`. The output is a reference for the other commands that use the **Exclude** and **Recurse** parameters. ```powershell @@ -239,7 +277,7 @@ d----- 2/15/2019 13:21 Backup The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test\Logs`. The **Exclude** parameter uses the asterisk (`*`) wildcard to specify any files or directories that -begin with **A** or **a** are excluded from the output. +begin with `A` or `a` are excluded from the output. When the **Exclude** parameter is used, a trailing asterisk (`*`) in the **Path** parameter is optional. For example, `-Path C:\Test\Logs` or `-Path C:\Test\Logs\*`. @@ -298,18 +336,18 @@ parameter only works on subkeys, not item properties. ### Example 7: Get all certificates with code-signing authority -This example gets each certificate in the PowerShell **Cert:** drive that has code-signing -authority. +This example gets each certificate in the PowerShell `Cert:` drive that has code-signing authority. -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the **Cert:** provider. The -**Recurse** parameter searches the directory specified by **Path** and its subdirectories. The -**CodeSigningCert** parameter gets only certificates that have code-signing authority. +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the Certificate provider with the +`Cert:` drive. The **Recurse** parameter searches the directory specified by **Path** and its +subdirectories. The **CodeSigningCert** parameter gets only certificates that have code-signing +authority. ```powershell Get-ChildItem -Path Cert:\* -Recurse -CodeSigningCert ``` -For more information about the Certificate provider and the Cert: drive, +For more information about the Certificate provider and the `Cert:` drive, see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). ### Example 8: Get items using the Depth parameter @@ -345,11 +383,11 @@ d----- 2/14/2019 10:22 SubDir_Level3 -a---- 2/13/2019 08:55 26 file.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify **C:\Parent**. The **Depth** +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify `C:\Parent`. The **Depth** parameter specifies two levels of recursion. `Get-ChildItem` displays the contents of the directory specified by the **Path** parameter and the two levels of subdirectories. -### Example 9 - Get the link target for a junction point +### Example 9: Get the link target for a junction point The `dir` command in the Windows Command Shell shows the target location of a filesystem junction point. In PowerShell, this information is available from the **Target** property of the filesystem @@ -357,17 +395,40 @@ object returned by `Get-ChildItem`. ```powershell PS D:\> New-Item -ItemType Junction -Name tmp -Target $env:TEMP -PS D:\> Get-ChildItem | select name,*target +PS D:\> Get-ChildItem | Select-Object name,*target Name Target ---- ------ tmp {C:\Users\user1\AppData\Local\Temp} ``` +### Example 10: Get the link target for an AppX reparse point + +This example attempts to get the target information for an AppX reparse point. Microsoft Store +applications create AppX reparse points in the user's AppData directory. + +```powershell +Get-ChildItem ~\AppData\Local\Microsoft\WindowsApps\MicrosoftEdge.exe | + Select-Object Mode, LinkTarget, LinkType, Name +``` + +```Output +Mode LinkTarget LinkType Name +---- ---------- -------- ---- +la--- MicrosoftEdge.exe +``` + +At this time, Windows doesn't provide a way to get the target information for an AppX reparse point. +The **LinkTarget** and **LinkType** properties of the filesystem object are empty. + ## PARAMETERS ### -Attributes +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + Gets files and folders with the specified attributes. This parameter supports all attributes and lets you specify complex combinations of attributes. @@ -427,6 +488,27 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -CodeSigningCert + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Code Signing` in their **EnhancedKeyUsageList** property +value, use the **CodeSigningCert** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Depth This parameter was added in PowerShell 5.0 and enables you to control the depth of recursion. By @@ -434,7 +516,7 @@ default, `Get-ChildItem` displays the contents of the parent directory. The **De determines the number of subdirectory levels that are included in the recursion and displays the contents. -For example, `Depth 2` includes the **Path** parameter's directory, first level of subdirectories, +For example, `-Depth 2` includes the **Path** parameter's directory, first level of subdirectories, and second level of subdirectories. By default directory names and filenames are included in the output. @@ -456,6 +538,10 @@ Accept wildcard characters: False ### -Directory +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get a list of directories, use the **Directory** parameter or the **Attributes** parameter with the **Directory** property. You can use the **Recurse** parameter with **Directory**. @@ -471,6 +557,75 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -DnsName + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies a domain name or name pattern to match with the **DNSNameList** property of certificates +the cmdlet gets. The value of this parameter can either be `Unicode` or `ASCII`. Punycode values +are converted to Unicode. Wildcard characters (`*`) are permitted. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: Microsoft.PowerShell.Commands.DnsNameRepresentation +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + +### -DocumentEncryptionCert + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Document Encryption` in their **EnhancedKeyUsageList** +property value, use the **DocumentEncryptionCert** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Eku + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies text or a text pattern to match with the **EnhancedKeyUsageList** property of +certificates the cmdlet gets. Wildcard characters (`*`) are permitted. The **EnhancedKeyUsageList** +property contains the friendly name and the OID fields of the EKU. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + ### -Exclude Specifies an array of one or more string patterns to be matched as the cmdlet gets child items. Any @@ -497,8 +652,35 @@ Accept pipeline input: False Accept wildcard characters: True ``` +### -ExpiringInDays + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies that the cmdlet should only return certificates that are expiring in or before the +specified number of days. A value of zero (`0`) gets certificates that have expired. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: System.Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -File +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get a list of files, use the **File** parameter. You can use the **Recurse** parameter with **File**. @@ -535,6 +717,31 @@ Accept pipeline input: False Accept wildcard characters: True ``` +### -FollowSymlink + +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + +By default, the `Get-ChildItem` cmdlet displays symbolic links to directories found during +recursion, but doesn't recurse into them. Use the **FollowSymlink** parameter to search the +directories that target those symbolic links. The **FollowSymlink** is a dynamic parameter and is +supported only in the **FileSystem** provider. + +This parameter was introduced in PowerShell 6.0. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Force Allows the cmdlet to get items that otherwise can't be accessed by the user, such as hidden or @@ -556,6 +763,10 @@ Accept wildcard characters: False ### -Hidden +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get only hidden items, use the **Hidden** parameter or the **Attributes** parameter with the **Hidden** property. By default, `Get-ChildItem` doesn't display hidden items. Use the **Force** parameter to get hidden items. @@ -653,6 +864,10 @@ Accept wildcard characters: True ### -ReadOnly +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get only read-only items, use the **ReadOnly** parameter or the **Attributes** parameter **ReadOnly** property. @@ -684,8 +899,33 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -SSLServerAuthentication + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Server Authentication` in their **EnhancedKeyUsageList** +property value, use the **SSLServerAuthentication** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -System +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + Gets only system files and directories. To get only system files and folders, use the **System** parameter or **Attributes** parameter **System** property. diff --git a/reference/7.2/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md b/reference/7.2/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md index 843aa449b697..955efa1a3380 100644 --- a/reference/7.2/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md +++ b/reference/7.2/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md @@ -1,7 +1,7 @@ --- description: FileSystem Locale: en-US -ms.date: 01/10/2023 +ms.date: 06/14/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_filesystem_provider?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 title: about FileSystem Provider @@ -73,9 +73,27 @@ instances of the [System.IO.DirectoryInfo][02] class. The PowerShell Extended Type System adds extra properties to these object types to provide additional information. Some information is platform specific. For example, the possible values of the **LinkType** property depend on the -platform and filesystem being used. On Windows, NTFS supports `HardLink`, -`SymLink`, and `Junction` values for **LinkType**. Linux and macOS filesystems -only support `HardLink` and `SymLink`. +platform and filesystem being used. Linux and macOS filesystems support +`HardLink` and `SymLink`. Windows NTFS supports `HardLink`, `SymLink`, +`Junction`, and several other values for **LinkType**. + +When you use `Get-Item` or `Get-ChildItem` to information about a linked item, +the **Mode** property contains an `l` to indicate that the item is a link. The +**LinkType** property contains the type of link. + +`AppExecLink` links are created when you install an application from the +Microsoft Store. For `AppExecLink` links, Windows doesn't provide values for +the **LinkType** or **LinkTarget** properties. + +```powershell +Get-Item ~\AppData\Local\Microsoft\WindowsApps\winget.exe + + Directory: C:\Users\user1\AppData\Local\Microsoft\WindowsApps + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +la--- 6/8/2023 12:20 PM 0 winget.exe -> +``` ## Navigating the FileSystem drives diff --git a/reference/7.2/Microsoft.PowerShell.Management/Get-ChildItem.md b/reference/7.2/Microsoft.PowerShell.Management/Get-ChildItem.md index afb9a586e4cc..5dbeffc194ec 100644 --- a/reference/7.2/Microsoft.PowerShell.Management/Get-ChildItem.md +++ b/reference/7.2/Microsoft.PowerShell.Management/Get-ChildItem.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management -ms.date: 12/13/2022 +ms.date: 06/14/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-ChildItem @@ -19,18 +19,55 @@ Gets the items and child items in one or more specified locations. ### Items (Default) ``` -Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] [-Exclude ] - [-Recurse] [-Depth ] [-Force] [-Name] [-Attributes ] - [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [] ``` ### LiteralItems ``` Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] - [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] - [-Attributes ] [-FollowSymlink] [-Directory] [-File] [-Hidden] - [-ReadOnly] [-System] [] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [] +``` + +### Items (Default) - Certificate provider + +``` +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-CodeSigningCert] [-DocumentEncryptionCert] [-SSLServerAuthentication] + [-DnsName ] [-Eku ] [-ExpiringInDays ] + [] +``` + +### LiteralItems - Certificate provider + +``` +Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-CodeSigningCert] [-DocumentEncryptionCert] [-SSLServerAuthentication] + [-DnsName ] [-Eku ] [-ExpiringInDays ] + [] +``` + +### Items (Default) - Filesystem provider + +``` +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-Attributes ] [-FollowSymlink] [-Directory] + [-File] [-Hidden] [-ReadOnly] [-System] [] +``` + +### LiteralItems - FileSystem provider + +``` +Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-Attributes ] [-FollowSymlink] [-Directory] + [-File] [-Hidden] [-ReadOnly] [-System] [] ``` ## DESCRIPTION @@ -44,7 +81,8 @@ of levels to recurse. **Depth** or **Recurse** parameters, empty directories aren't included in the output. Locations are exposed to `Get-ChildItem` by PowerShell providers. A location can be a file system -directory, registry hive, or a certificate store. For more information, see +directory, registry hive, or a certificate store. Some parameters are only available for a specific +provider. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). ## EXAMPLES @@ -83,7 +121,7 @@ as follows: - `a` (archive) - `r` (read-only) - `h` (hidden) -- `s` (system). +- `s` (system) For more information about the mode flags, see [about_Filesystem_Provider](../microsoft.powershell.core/about/about_filesystem_provider.md#attributes-flagsexpression). @@ -110,7 +148,7 @@ ReadOnlyFile.txt ### Example 3: Get child items in the current directory and subdirectories -This example displays **.txt** files that are located in the current directory and its +This example displays `.txt` files that are located in the current directory and its subdirectories. ```powershell @@ -186,10 +224,10 @@ Mode LastWriteTime Length Name -ar--- 2/12/2019 14:31 27 ReadOnlyFile.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory **C:\Test**. The +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test`. The **Path** parameter includes a trailing asterisk (`*`) wildcard to specify the directory's contents. The **Include** parameter uses an asterisk (`*`) wildcard to specify all files with the file name -extension **.txt**. +extension `.txt`. When the **Include** parameter is used, the **Path** parameter needs a trailing asterisk (`*`) wildcard to specify the directory's contents. For example, `-Path C:\Test\*`. @@ -202,7 +240,7 @@ wildcard to specify the directory's contents. For example, `-Path C:\Test\*`. ### Example 5: Get child items using the Exclude parameter -The example's output shows the contents of the directory **C:\Test\Logs**. The output is a reference +The example's output shows the contents of the directory `C:\Test\Logs`. The output is a reference for the other commands that use the **Exclude** and **Recurse** parameters. ```powershell @@ -238,7 +276,7 @@ d----- 2/15/2019 13:21 Backup The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test\Logs`. The **Exclude** parameter uses the asterisk (`*`) wildcard to specify any files or directories that -begin with **A** or **a** are excluded from the output. +begin with `A` or `a` are excluded from the output. When the **Exclude** parameter is used, a trailing asterisk (`*`) in the **Path** parameter is optional. For example, `-Path C:\Test\Logs` or `-Path C:\Test\Logs\*`. @@ -297,18 +335,18 @@ parameter only works on subkeys, not item properties. ### Example 7: Get all certificates with code-signing authority -This example gets each certificate in the PowerShell **Cert:** drive that has code-signing -authority. +This example gets each certificate in the PowerShell `Cert:` drive that has code-signing authority. -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the **Cert:** provider. The -**Recurse** parameter searches the directory specified by **Path** and its subdirectories. The -**CodeSigningCert** parameter gets only certificates that have code-signing authority. +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the Certificate provider with the +`Cert:` drive. The **Recurse** parameter searches the directory specified by **Path** and its +subdirectories. The **CodeSigningCert** parameter gets only certificates that have code-signing +authority. ```powershell Get-ChildItem -Path Cert:\* -Recurse -CodeSigningCert ``` -For more information about the Certificate provider and the Cert: drive, +For more information about the Certificate provider and the `Cert:` drive, see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). ### Example 8: Get items using the Depth parameter @@ -344,7 +382,7 @@ d----- 2/14/2019 10:22 SubDir_Level3 -a---- 2/13/2019 08:55 26 file.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify **C:\Parent**. The **Depth** +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify `C:\Parent`. The **Depth** parameter specifies two levels of recursion. `Get-ChildItem` displays the contents of the directory specified by the **Path** parameter and the two levels of subdirectories. @@ -391,7 +429,7 @@ The new properties that are now part of the output are: > [!NOTE] > This feature was moved from experimental to mainstream in PowerShell 7.1. -### Example 11 - Get the link target for a junction point +### Example 11: Get the link target for a junction point The `dir` command in the Windows Command Shell shows the target location of a filesystem junction point. In PowerShell, this information is available from the **LinkTarget** property of the @@ -399,7 +437,7 @@ filesystem object returned by `Get-ChildItem` and is displayed in the default ou ```powershell PS D:\> New-Item -ItemType Junction -Name tmp -Target $env:TEMP -PS D:\> Get-ChildItem | select name,LinkTarget +PS D:\> Get-ChildItem | Select-Object name,LinkTarget Name LinkTarget ---- ---------- @@ -414,10 +452,33 @@ Mode LastWriteTime Length Name l---- 12/16/2021 9:29 AM tmp -> C:\Users\user1\AppData\Local\Temp ``` +### Example 12: Get the link target for an AppX reparse point + +This example attempts to get the target information for an AppX reparse point. Microsoft Store +applications create AppX reparse points in the user's AppData directory. + +```powershell +Get-ChildItem ~\AppData\Local\Microsoft\WindowsApps\MicrosoftEdge.exe | + Select-Object Mode, LinkTarget, LinkType, Name +``` + +```Output +Mode LinkTarget LinkType Name +---- ---------- -------- ---- +la--- MicrosoftEdge.exe +``` + +At this time, Windows doesn't provide a way to get the target information for an AppX reparse point. +The **LinkTarget** and **LinkType** properties of the filesystem object are empty. + ## PARAMETERS ### -Attributes +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + Gets files and folders with the specified attributes. This parameter supports all attributes and lets you specify complex combinations of attributes. @@ -477,6 +538,27 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -CodeSigningCert + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Code Signing` in their **EnhancedKeyUsageList** property +value, use the **CodeSigningCert** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Depth This parameter was added in PowerShell 5.0 and enables you to control the depth of recursion. By @@ -484,7 +566,7 @@ default, `Get-ChildItem` displays the contents of the parent directory. The **De determines the number of subdirectory levels that are included in the recursion and displays the contents. -For example, `Depth 2` includes the **Path** parameter's directory, first level of subdirectories, +For example, `-Depth 2` includes the **Path** parameter's directory, first level of subdirectories, and second level of subdirectories. By default directory names and filenames are included in the output. @@ -506,6 +588,10 @@ Accept wildcard characters: False ### -Directory +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get a list of directories, use the **Directory** parameter or the **Attributes** parameter with the **Directory** property. You can use the **Recurse** parameter with **Directory**. @@ -521,6 +607,75 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -DnsName + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies a domain name or name pattern to match with the **DNSNameList** property of certificates +the cmdlet gets. The value of this parameter can either be `Unicode` or `ASCII`. Punycode values +are converted to Unicode. Wildcard characters (`*`) are permitted. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: Microsoft.PowerShell.Commands.DnsNameRepresentation +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + +### -DocumentEncryptionCert + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Document Encryption` in their **EnhancedKeyUsageList** +property value, use the **DocumentEncryptionCert** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Eku + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies text or a text pattern to match with the **EnhancedKeyUsageList** property of +certificates the cmdlet gets. Wildcard characters (`*`) are permitted. The **EnhancedKeyUsageList** +property contains the friendly name and the OID fields of the EKU. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + ### -Exclude Specifies an array of one or more string patterns to be matched as the cmdlet gets child items. Any @@ -547,8 +702,35 @@ Accept pipeline input: False Accept wildcard characters: True ``` +### -ExpiringInDays + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies that the cmdlet should only return certificates that are expiring in or before the +specified number of days. A value of zero (`0`) gets certificates that have expired. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: System.Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -File +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get a list of files, use the **File** parameter. You can use the **Recurse** parameter with **File**. @@ -587,6 +769,10 @@ Accept wildcard characters: True ### -FollowSymlink +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + By default, the `Get-ChildItem` cmdlet displays symbolic links to directories found during recursion, but doesn't recurse into them. Use the **FollowSymlink** parameter to search the directories that target those symbolic links. The **FollowSymlink** is a dynamic parameter and is @@ -627,6 +813,10 @@ Accept wildcard characters: False ### -Hidden +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get only hidden items, use the **Hidden** parameter or the **Attributes** parameter with the **Hidden** property. By default, `Get-ChildItem` doesn't display hidden items. Use the **Force** parameter to get hidden items. @@ -724,6 +914,10 @@ Accept wildcard characters: True ### -ReadOnly +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get only read-only items, use the **ReadOnly** parameter or the **Attributes** parameter **ReadOnly** property. @@ -755,8 +949,33 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -SSLServerAuthentication + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Server Authentication` in their **EnhancedKeyUsageList** +property value, use the **SSLServerAuthentication** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -System +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + Gets only system files and directories. To get only system files and folders, use the **System** parameter or **Attributes** parameter **System** property. diff --git a/reference/7.3/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md b/reference/7.3/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md index 799a02372e43..8ed7e528f444 100644 --- a/reference/7.3/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md +++ b/reference/7.3/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md @@ -1,7 +1,7 @@ --- description: FileSystem Locale: en-US -ms.date: 01/10/2023 +ms.date: 06/14/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_filesystem_provider?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 title: about FileSystem Provider @@ -73,9 +73,27 @@ instances of the [System.IO.DirectoryInfo][02] class. The PowerShell Extended Type System adds extra properties to these object types to provide additional information. Some information is platform specific. For example, the possible values of the **LinkType** property depend on the -platform and filesystem being used. On Windows, NTFS supports `HardLink`, -`SymLink`, and `Junction` values for **LinkType**. Linux and macOS filesystems -only support `HardLink` and `SymLink`. +platform and filesystem being used. Linux and macOS filesystems support +`HardLink` and `SymLink`. Windows NTFS supports `HardLink`, `SymLink`, +`Junction`, and several other values for **LinkType**. + +When you use `Get-Item` or `Get-ChildItem` to information about a linked item, +the **Mode** property contains an `l` to indicate that the item is a link. The +**LinkType** property contains the type of link. + +`AppExecLink` links are created when you install an application from the +Microsoft Store. For `AppExecLink` links, Windows doesn't provide values for +the **LinkType** or **LinkTarget** properties. + +```powershell +Get-Item ~\AppData\Local\Microsoft\WindowsApps\winget.exe + + Directory: C:\Users\user1\AppData\Local\Microsoft\WindowsApps + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +la--- 6/8/2023 12:20 PM 0 winget.exe -> +``` ## Navigating the FileSystem drives diff --git a/reference/7.3/Microsoft.PowerShell.Management/Get-ChildItem.md b/reference/7.3/Microsoft.PowerShell.Management/Get-ChildItem.md index 2ddc907c701e..ff76ded5cc20 100644 --- a/reference/7.3/Microsoft.PowerShell.Management/Get-ChildItem.md +++ b/reference/7.3/Microsoft.PowerShell.Management/Get-ChildItem.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management -ms.date: 12/13/2022 +ms.date: 06/14/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-ChildItem @@ -121,7 +121,7 @@ as follows: - `a` (archive) - `r` (read-only) - `h` (hidden) -- `s` (system). +- `s` (system) For more information about the mode flags, see [about_Filesystem_Provider](../microsoft.powershell.core/about/about_filesystem_provider.md#attributes-flagsexpression). @@ -429,7 +429,7 @@ The new properties that are now part of the output are: > [!NOTE] > This feature was moved from experimental to mainstream in PowerShell 7.1. -### Example 11 - Get the link target for a junction point +### Example 11: Get the link target for a junction point The `dir` command in the Windows Command Shell shows the target location of a filesystem junction point. In PowerShell, this information is available from the **LinkTarget** property of the @@ -437,7 +437,7 @@ filesystem object returned by `Get-ChildItem` and is displayed in the default ou ```powershell PS D:\> New-Item -ItemType Junction -Name tmp -Target $env:TEMP -PS D:\> Get-ChildItem | select name,LinkTarget +PS D:\> Get-ChildItem | Select-Object name,LinkTarget Name LinkTarget ---- ---------- @@ -452,6 +452,25 @@ Mode LastWriteTime Length Name l---- 12/16/2021 9:29 AM tmp -> C:\Users\user1\AppData\Local\Temp ``` +### Example 12: Get the link target for an AppX reparse point + +This example attempts to get the target information for an AppX reparse point. Microsoft Store +applications create AppX reparse points in the user's AppData directory. + +```powershell +Get-ChildItem ~\AppData\Local\Microsoft\WindowsApps\MicrosoftEdge.exe | + Select-Object Mode, LinkTarget, LinkType, Name +``` + +```Output +Mode LinkTarget LinkType Name +---- ---------- -------- ---- +la--- MicrosoftEdge.exe +``` + +At this time, Windows doesn't provide a way to get the target information for an AppX reparse point. +The **LinkTarget** and **LinkType** properties of the filesystem object are empty. + ## PARAMETERS ### -Attributes diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md index 586f6d9f4ef8..0425403b5202 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md @@ -1,7 +1,7 @@ --- description: FileSystem Locale: en-US -ms.date: 01/10/2023 +ms.date: 06/14/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_filesystem_provider?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: about FileSystem Provider @@ -73,9 +73,27 @@ instances of the [System.IO.DirectoryInfo][02] class. The PowerShell Extended Type System adds extra properties to these object types to provide additional information. Some information is platform specific. For example, the possible values of the **LinkType** property depend on the -platform and filesystem being used. On Windows, NTFS supports `HardLink`, -`SymLink`, and `Junction` values for **LinkType**. Linux and macOS filesystems -only support `HardLink` and `SymLink`. +platform and filesystem being used. Linux and macOS filesystems support +`HardLink` and `SymLink`. Windows NTFS supports `HardLink`, `SymLink`, +`Junction`, and several other values for **LinkType**. + +When you use `Get-Item` or `Get-ChildItem` to information about a linked item, +the **Mode** property contains an `l` to indicate that the item is a link. The +**LinkType** property contains the type of link. + +`AppExecLink` links are created when you install an application from the +Microsoft Store. For `AppExecLink` links, Windows doesn't provide values for +the **LinkType** or **LinkTarget** properties. + +```powershell +Get-Item ~\AppData\Local\Microsoft\WindowsApps\winget.exe + + Directory: C:\Users\user1\AppData\Local\Microsoft\WindowsApps + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +la--- 6/8/2023 12:20 PM 0 winget.exe -> +``` ## Navigating the FileSystem drives diff --git a/reference/7.4/Microsoft.PowerShell.Management/Get-ChildItem.md b/reference/7.4/Microsoft.PowerShell.Management/Get-ChildItem.md index 7586bc8e9305..abc74de1cd35 100644 --- a/reference/7.4/Microsoft.PowerShell.Management/Get-ChildItem.md +++ b/reference/7.4/Microsoft.PowerShell.Management/Get-ChildItem.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management -ms.date: 12/13/2022 +ms.date: 06/14/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-ChildItem @@ -19,18 +19,55 @@ Gets the items and child items in one or more specified locations. ### Items (Default) ``` -Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] [-Exclude ] - [-Recurse] [-Depth ] [-Force] [-Name] [-Attributes ] - [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [] ``` ### LiteralItems ``` Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] - [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] - [-Attributes ] [-FollowSymlink] [-Directory] [-File] [-Hidden] - [-ReadOnly] [-System] [] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [] +``` + +### Items (Default) - Certificate provider + +``` +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-CodeSigningCert] [-DocumentEncryptionCert] [-SSLServerAuthentication] + [-DnsName ] [-Eku ] [-ExpiringInDays ] + [] +``` + +### LiteralItems - Certificate provider + +``` +Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-CodeSigningCert] [-DocumentEncryptionCert] [-SSLServerAuthentication] + [-DnsName ] [-Eku ] [-ExpiringInDays ] + [] +``` + +### Items (Default) - Filesystem provider + +``` +Get-ChildItem [[-Path] ] [[-Filter] ] [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-Attributes ] [-FollowSymlink] [-Directory] + [-File] [-Hidden] [-ReadOnly] [-System] [] +``` + +### LiteralItems - FileSystem provider + +``` +Get-ChildItem [[-Filter] ] -LiteralPath [-Include ] + [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] + [-Attributes ] [-FollowSymlink] [-Directory] + [-File] [-Hidden] [-ReadOnly] [-System] [] ``` ## DESCRIPTION @@ -44,7 +81,8 @@ of levels to recurse. **Depth** or **Recurse** parameters, empty directories aren't included in the output. Locations are exposed to `Get-ChildItem` by PowerShell providers. A location can be a file system -directory, registry hive, or a certificate store. For more information, see +directory, registry hive, or a certificate store. Some parameters are only available for a specific +provider. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). ## EXAMPLES @@ -83,7 +121,7 @@ as follows: - `a` (archive) - `r` (read-only) - `h` (hidden) -- `s` (system). +- `s` (system) For more information about the mode flags, see [about_Filesystem_Provider](../microsoft.powershell.core/about/about_filesystem_provider.md#attributes-flagsexpression). @@ -110,7 +148,7 @@ ReadOnlyFile.txt ### Example 3: Get child items in the current directory and subdirectories -This example displays **.txt** files that are located in the current directory and its +This example displays `.txt` files that are located in the current directory and its subdirectories. ```powershell @@ -186,10 +224,10 @@ Mode LastWriteTime Length Name -ar--- 2/12/2019 14:31 27 ReadOnlyFile.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory **C:\Test**. The +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test`. The **Path** parameter includes a trailing asterisk (`*`) wildcard to specify the directory's contents. The **Include** parameter uses an asterisk (`*`) wildcard to specify all files with the file name -extension **.txt**. +extension `.txt`. When the **Include** parameter is used, the **Path** parameter needs a trailing asterisk (`*`) wildcard to specify the directory's contents. For example, `-Path C:\Test\*`. @@ -202,7 +240,7 @@ wildcard to specify the directory's contents. For example, `-Path C:\Test\*`. ### Example 5: Get child items using the Exclude parameter -The example's output shows the contents of the directory **C:\Test\Logs**. The output is a reference +The example's output shows the contents of the directory `C:\Test\Logs`. The output is a reference for the other commands that use the **Exclude** and **Recurse** parameters. ```powershell @@ -238,7 +276,7 @@ d----- 2/15/2019 13:21 Backup The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test\Logs`. The **Exclude** parameter uses the asterisk (`*`) wildcard to specify any files or directories that -begin with **A** or **a** are excluded from the output. +begin with `A` or `a` are excluded from the output. When the **Exclude** parameter is used, a trailing asterisk (`*`) in the **Path** parameter is optional. For example, `-Path C:\Test\Logs` or `-Path C:\Test\Logs\*`. @@ -297,18 +335,18 @@ parameter only works on subkeys, not item properties. ### Example 7: Get all certificates with code-signing authority -This example gets each certificate in the PowerShell **Cert:** drive that has code-signing -authority. +This example gets each certificate in the PowerShell `Cert:` drive that has code-signing authority. -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the **Cert:** provider. The -**Recurse** parameter searches the directory specified by **Path** and its subdirectories. The -**CodeSigningCert** parameter gets only certificates that have code-signing authority. +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the Certificate provider with the +`Cert:` drive. The **Recurse** parameter searches the directory specified by **Path** and its +subdirectories. The **CodeSigningCert** parameter gets only certificates that have code-signing +authority. ```powershell Get-ChildItem -Path Cert:\* -Recurse -CodeSigningCert ``` -For more information about the Certificate provider and the Cert: drive, +For more information about the Certificate provider and the `Cert:` drive, see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). ### Example 8: Get items using the Depth parameter @@ -344,7 +382,7 @@ d----- 2/14/2019 10:22 SubDir_Level3 -a---- 2/13/2019 08:55 26 file.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify **C:\Parent**. The **Depth** +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify `C:\Parent`. The **Depth** parameter specifies two levels of recursion. `Get-ChildItem` displays the contents of the directory specified by the **Path** parameter and the two levels of subdirectories. @@ -391,7 +429,7 @@ The new properties that are now part of the output are: > [!NOTE] > This feature was moved from experimental to mainstream in PowerShell 7.1. -### Example 11 - Get the link target for a junction point +### Example 11: Get the link target for a junction point The `dir` command in the Windows Command Shell shows the target location of a filesystem junction point. In PowerShell, this information is available from the **LinkTarget** property of the @@ -399,7 +437,7 @@ filesystem object returned by `Get-ChildItem` and is displayed in the default ou ```powershell PS D:\> New-Item -ItemType Junction -Name tmp -Target $env:TEMP -PS D:\> Get-ChildItem | select name,LinkTarget +PS D:\> Get-ChildItem | Select-Object name,LinkTarget Name LinkTarget ---- ---------- @@ -414,10 +452,33 @@ Mode LastWriteTime Length Name l---- 12/16/2021 9:29 AM tmp -> C:\Users\user1\AppData\Local\Temp ``` +### Example 12: Get the link target for an AppX reparse point + +This example attempts to get the target information for an AppX reparse point. Microsoft Store +applications create AppX reparse points in the user's AppData directory. + +```powershell +Get-ChildItem ~\AppData\Local\Microsoft\WindowsApps\MicrosoftEdge.exe | + Select-Object Mode, LinkTarget, LinkType, Name +``` + +```Output +Mode LinkTarget LinkType Name +---- ---------- -------- ---- +la--- MicrosoftEdge.exe +``` + +At this time, Windows doesn't provide a way to get the target information for an AppX reparse point. +The **LinkTarget** and **LinkType** properties of the filesystem object are empty. + ## PARAMETERS ### -Attributes +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + Gets files and folders with the specified attributes. This parameter supports all attributes and lets you specify complex combinations of attributes. @@ -477,6 +538,27 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -CodeSigningCert + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Code Signing` in their **EnhancedKeyUsageList** property +value, use the **CodeSigningCert** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Depth This parameter was added in PowerShell 5.0 and enables you to control the depth of recursion. By @@ -484,7 +566,7 @@ default, `Get-ChildItem` displays the contents of the parent directory. The **De determines the number of subdirectory levels that are included in the recursion and displays the contents. -For example, `Depth 2` includes the **Path** parameter's directory, first level of subdirectories, +For example, `-Depth 2` includes the **Path** parameter's directory, first level of subdirectories, and second level of subdirectories. By default directory names and filenames are included in the output. @@ -506,6 +588,10 @@ Accept wildcard characters: False ### -Directory +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get a list of directories, use the **Directory** parameter or the **Attributes** parameter with the **Directory** property. You can use the **Recurse** parameter with **Directory**. @@ -521,6 +607,75 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -DnsName + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies a domain name or name pattern to match with the **DNSNameList** property of certificates +the cmdlet gets. The value of this parameter can either be `Unicode` or `ASCII`. Punycode values +are converted to Unicode. Wildcard characters (`*`) are permitted. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: Microsoft.PowerShell.Commands.DnsNameRepresentation +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + +### -DocumentEncryptionCert + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Document Encryption` in their **EnhancedKeyUsageList** +property value, use the **DocumentEncryptionCert** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Eku + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies text or a text pattern to match with the **EnhancedKeyUsageList** property of +certificates the cmdlet gets. Wildcard characters (`*`) are permitted. The **EnhancedKeyUsageList** +property contains the friendly name and the OID fields of the EKU. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: True +``` + ### -Exclude Specifies an array of one or more string patterns to be matched as the cmdlet gets child items. Any @@ -547,8 +702,35 @@ Accept pipeline input: False Accept wildcard characters: True ``` +### -ExpiringInDays + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +Specifies that the cmdlet should only return certificates that are expiring in or before the +specified number of days. A value of zero (`0`) gets certificates that have expired. + +This parameter was reintroduced in PowerShell 7.1 + +```yaml +Type: System.Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -File +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get a list of files, use the **File** parameter. You can use the **Recurse** parameter with **File**. @@ -587,6 +769,10 @@ Accept wildcard characters: True ### -FollowSymlink +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + By default, the `Get-ChildItem` cmdlet displays symbolic links to directories found during recursion, but doesn't recurse into them. Use the **FollowSymlink** parameter to search the directories that target those symbolic links. The **FollowSymlink** is a dynamic parameter and is @@ -627,6 +813,10 @@ Accept wildcard characters: False ### -Hidden +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get only hidden items, use the **Hidden** parameter or the **Attributes** parameter with the **Hidden** property. By default, `Get-ChildItem` doesn't display hidden items. Use the **Force** parameter to get hidden items. @@ -724,6 +914,10 @@ Accept wildcard characters: True ### -ReadOnly +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + To get only read-only items, use the **ReadOnly** parameter or the **Attributes** parameter **ReadOnly** property. @@ -755,8 +949,33 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -SSLServerAuthentication + +> [!NOTE] +> This parameter is only available in the +> [Certificate](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md) provider. + +To get a list of certificates that have `Server Authentication` in their **EnhancedKeyUsageList** +property value, use the **SSLServerAuthentication** parameter. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -System +> [!NOTE] +> This parameter is only available in the +> [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider. + Gets only system files and directories. To get only system files and folders, use the **System** parameter or **Attributes** parameter **System** property.