Skip to content

Commit 112dbd8

Browse files
kiazhijuanpablojofre
authored andcommitted
Update Parameters & Examples section
Rearrange Parameters in Alphabetical order Update Examples Heading
1 parent 46f1605 commit 112dbd8

File tree

1 file changed

+92
-85
lines changed

1 file changed

+92
-85
lines changed

reference/6/Microsoft.PowerShell.Management/Get-ChildItem.md

Lines changed: 92 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A location can be a file system location, such as a directory, or a location exp
4242

4343
## Examples
4444

45-
### Example 1
45+
### Example 1: Get child items in the current directory
4646
```powershell
4747
Get-ChildItem
4848
```
@@ -54,7 +54,7 @@ If the item does not have child items, this command returns to the command promp
5454
The default display lists the mode (attributes), last write time, file size (length), and the name of the file.
5555
The valid values for mode are `d` (directory), `a` (archive), `r` (read-only), `h` (hidden), and `s` (system).
5656

57-
### Example 2
57+
### Example 2: Get all files with the specified file extension in the current directory and subdirectories
5858
```powershell
5959
Get-ChildItem -Path *.txt -Recurse -Force
6060
```
@@ -67,7 +67,7 @@ To use the `-Recurse` parameter on Windows PowerShell 2.0 and earlier versions o
6767
Use the `-Include` parameter to specify the .txt file type.
6868
For example, `Get-ChildItem -Path .\* -Include *.txt -Recurse`
6969

70-
### Example 3
70+
### Example 3: Get all child items using an inclusion and exclusion
7171
```powershell
7272
Get-ChildItem -Path C:\Windows\Logs\* -Include *.txt -Exclude A*
7373
```
@@ -76,21 +76,21 @@ This command lists the .txt files in the Logs subdirectory, except for those who
7676
It uses the wildcard character (`*`) to indicate the contents of the Logs subdirectory, not the directory container.
7777
Because the command does not include the `-Recurse` parameter, `Get-ChildItem` does not include the content of directory automatically; you need to specify it.
7878

79-
### Example 4
79+
### Example 4: Get all registry keys in a specific key
8080
```powershell
8181
Get-ChildItem -Path HKLM:\Software
8282
```
8383

8484
This command gets all of the registry keys in the HKEY_LOCAL_MACHINE\SOFTWARE key in the registry of the local computer.
8585

86-
### Example 5
86+
### Example 5: Get the name of items in the current directory
8787
```powershell
8888
Get-ChildItem -Name
8989
```
9090

9191
This command gets only the names of items in the current directory.
9292

93-
### Example 6
93+
### Example 6: Get all certificates in a certification drive that have code-signing authority
9494
```powershell
9595
Import-Module Microsoft.PowerShell.Security
9696
Get-ChildItem -Path Cert:\* -Recurse -CodeSigningCert
@@ -109,13 +109,20 @@ This parameter gets only certificates that have code-signing authority.
109109

110110
For more information about the Certificate provider and the Cert: drive, go to [Certificate Provider](../../Microsoft.PowerShell.Security/Providers/certificate-provider.md) or use the `Update-Help` cmdlet to download the help files for the Microsoft.PowerShell.Security module and then type `Get-Help Certificate`.
111111

112-
### Example 7
112+
### Example 7: Get all items in the specified directory and its subdirectories that have an inclusion and exclusion
113113
```powershell
114114
Get-ChildItem -Path C:\Windows -Include *mouse* -Exclude *.png
115115
```
116116

117117
This command gets all of the items in the C:\Windows directory and its subdirectories that have "mouse" in the file name, except for those with a .png file name extension.
118118

119+
### Example 8: Get all items in the specified directory and its subdirectories limited by the Depth parameter
120+
```
121+
PS C:\> Get-ChildItem -Path C:\Windows -Depth 2
122+
```
123+
124+
This command gets all of the items in the C:\Windows directory and its subdirectories up to 2 level below in depth.
125+
119126
## Parameters
120127

121128
### -Attributes
@@ -171,17 +178,13 @@ Accept pipeline input: False
171178
Accept wildcard characters: False
172179
```
173180
174-
### -Directory
175-
Gets directories (folders).
176-
177-
To get only directories, use the `-Directory` parameter and omit the `-File` parameter. To exclude directories, use the `-File` parameter and omit the `-Directory` parameter, or use the `-Attributes` parameter.
178-
179-
To get directories, use the Directory parameter, its "`ad`" alias, or the Directory attribute of the `-Attributes` parameter.
181+
### -Depth
182+
This parameter, added in Powershell 5.0 enables you to control the depth of recursion. You use both the `-Recurse` and the `-Depth` parameter to limit the recursion.
180183

181184
```yaml
182-
Type: SwitchParameter
185+
Type: UInt32
183186
Parameter Sets: (All)
184-
Aliases: ad, d
187+
Aliases:
185188
186189
Required: False
187190
Position: Named
@@ -190,17 +193,17 @@ Accept pipeline input: False
190193
Accept wildcard characters: False
191194
```
192195

193-
### -File
194-
Gets files.
196+
### -Directory
197+
Gets directories (folders).
195198

196-
To get only files, use the `-File` parameter and omit the Directory parameter. To exclude files, use the `-Directory` parameter and omit the `-File` parameter, or use the `-Attributes` parameter.
199+
To get only directories, use the `-Directory` parameter and omit the `-File` parameter. To exclude directories, use the `-File` parameter and omit the `-Directory` parameter, or use the `-Attributes` parameter.
197200

198-
To get files, use the File parameter, its "`af`" alias, or the File value of the `-Attributes` parameter.
201+
To get directories, use the Directory parameter, its "`ad`" alias, or the Directory attribute of the `-Attributes` parameter.
199202

200203
```yaml
201204
Type: SwitchParameter
202205
Parameter Sets: (All)
203-
Aliases: af
206+
Aliases: ad, d
204207
205208
Required: False
206209
Position: Named
@@ -209,32 +212,35 @@ Accept pipeline input: False
209212
Accept wildcard characters: False
210213
```
211214

212-
### -Hidden
213-
Gets only hidden files and directories (folders). By default, `Get-ChildItem` gets only non-hidden items, but you can use the `-Force` parameter to include hidden items in the results.
214-
215-
To get only hidden items, use the `-Hidden` parameter, its "`h`" or "`ah`" aliases, or the Hidden value of the `-Attributes` parameter. To exclude hidden items, omit the `-Hidden` parameter or use the `-Attributes` parameter.
215+
### -Exclude
216+
Omits the specified items.
217+
The value of this parameter qualifies the `-Path` parameter.
218+
Enter a path element or pattern, such as "*.txt".
219+
Wildcards are permitted.
216220

217221
```yaml
218-
Type: SwitchParameter
222+
Type: String[]
219223
Parameter Sets: (All)
220-
Aliases: ah, h
224+
Aliases:
221225
222226
Required: False
223227
Position: Named
224228
Default value: None
225229
Accept pipeline input: False
226-
Accept wildcard characters: False
230+
Accept wildcard characters: True
227231
```
228232

229-
### -ReadOnly
230-
Gets only read-only files and directories (folders).
233+
### -File
234+
Gets files.
231235

232-
To get only read-only items, use the `-ReadOnly` parameter, its "`ar`" alias, or the ReadOnly value of the `-Attributes` parameter. To exclude read-only items, use the `-Attributes` parameter.
236+
To get only files, use the `-File` parameter and omit the Directory parameter. To exclude files, use the `-Directory` parameter and omit the `-File` parameter, or use the `-Attributes` parameter.
237+
238+
To get files, use the File parameter, its "`af`" alias, or the File value of the `-Attributes` parameter.
233239

234240
```yaml
235241
Type: SwitchParameter
236242
Parameter Sets: (All)
237-
Aliases: ar
243+
Aliases: af
238244
239245
Required: False
240246
Position: Named
@@ -243,21 +249,22 @@ Accept pipeline input: False
243249
Accept wildcard characters: False
244250
```
245251

246-
### -System
247-
Gets only system files and directories (folders).
248-
249-
To get only system files and folders, use the `-System` parameter, its "`as`" alias, or the System value of the `-Attributes` parameter. To exclude system files and folders, use the `-Attributes` parameter.
252+
### -Filter
253+
Specifies a filter in the provider's format or language.
254+
The value of this parameter qualifies the `-Path` parameter.
255+
The syntax of the filter, including the use of wildcards, depends on the provider.
256+
Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved.
250257

251258
```yaml
252-
Type: SwitchParameter
259+
Type: String
253260
Parameter Sets: (All)
254-
Aliases: as
261+
Aliases:
255262
256263
Required: False
257-
Position: Named
264+
Position: 2
258265
Default value: None
259266
Accept pipeline input: False
260-
Accept wildcard characters: False
267+
Accept wildcard characters: True
261268
```
262269

263270
### -Force
@@ -278,57 +285,21 @@ Accept pipeline input: False
278285
Accept wildcard characters: False
279286
```
280287

281-
### -UseTransaction
282-
Includes the command in the active transaction.
283-
This parameter is valid only when a transaction is in progress.
284-
For more information, see about_Transactions.
285-
286-
```yaml
287-
Type: SwitchParameter
288-
Parameter Sets: (All)
289-
Aliases: usetx
290-
291-
Required: False
292-
Position: Named
293-
Default value: False
294-
Accept pipeline input: False
295-
Accept wildcard characters: False
296-
```
288+
### -Hidden
289+
Gets only hidden files and directories (folders). By default, `Get-ChildItem` gets only non-hidden items, but you can use the `-Force` parameter to include hidden items in the results.
297290

298-
### -Exclude
299-
Omits the specified items.
300-
The value of this parameter qualifies the `-Path` parameter.
301-
Enter a path element or pattern, such as "*.txt".
302-
Wildcards are permitted.
291+
To get only hidden items, use the `-Hidden` parameter, its "`h`" or "`ah`" aliases, or the Hidden value of the `-Attributes` parameter. To exclude hidden items, omit the `-Hidden` parameter or use the `-Attributes` parameter.
303292

304293
```yaml
305-
Type: String[]
294+
Type: SwitchParameter
306295
Parameter Sets: (All)
307-
Aliases:
296+
Aliases: ah, h
308297
309298
Required: False
310299
Position: Named
311300
Default value: None
312301
Accept pipeline input: False
313-
Accept wildcard characters: True
314-
```
315-
316-
### -Filter
317-
Specifies a filter in the provider's format or language.
318-
The value of this parameter qualifies the `-Path` parameter.
319-
The syntax of the filter, including the use of wildcards, depends on the provider.
320-
Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved.
321-
322-
```yaml
323-
Type: String
324-
Parameter Sets: (All)
325-
Aliases:
326-
327-
Required: False
328-
Position: 2
329-
Default value: None
330-
Accept pipeline input: False
331-
Accept wildcard characters: True
302+
Accept wildcard characters: False
332303
```
333304

334305
### -Include
@@ -403,6 +374,23 @@ Accept pipeline input: True (ByPropertyName, ByValue)
403374
Accept wildcard characters: True
404375
```
405376

377+
### -ReadOnly
378+
Gets only read-only files and directories (folders).
379+
380+
To get only read-only items, use the `-ReadOnly` parameter, its "`ar`" alias, or the ReadOnly value of the `-Attributes` parameter. To exclude read-only items, use the `-Attributes` parameter.
381+
382+
```yaml
383+
Type: SwitchParameter
384+
Parameter Sets: (All)
385+
Aliases: ar
386+
387+
Required: False
388+
Position: Named
389+
Default value: None
390+
Accept pipeline input: False
391+
Accept wildcard characters: False
392+
```
393+
406394
### -Recurse
407395
Gets the items in the specified locations and in all child items of the locations.
408396

@@ -420,13 +408,15 @@ Accept pipeline input: False
420408
Accept wildcard characters: False
421409
```
422410

423-
### -Depth
424-
This parameter, added in Powershell 5.0 enables you to control the depth of recursion. You use both the `-Recurse` and the `-Depth` parameter to limit the recursion.
411+
### -System
412+
Gets only system files and directories (folders).
413+
414+
To get only system files and folders, use the `-System` parameter, its "`as`" alias, or the System value of the `-Attributes` parameter. To exclude system files and folders, use the `-Attributes` parameter.
425415

426416
```yaml
427-
Type: UInt32
417+
Type: SwitchParameter
428418
Parameter Sets: (All)
429-
Aliases:
419+
Aliases: as
430420
431421
Required: False
432422
Position: Named
@@ -435,6 +425,23 @@ Accept pipeline input: False
435425
Accept wildcard characters: False
436426
```
437427

428+
### -UseTransaction
429+
Includes the command in the active transaction.
430+
This parameter is valid only when a transaction is in progress.
431+
For more information, see about_Transactions.
432+
433+
```yaml
434+
Type: SwitchParameter
435+
Parameter Sets: (All)
436+
Aliases: usetx
437+
438+
Required: False
439+
Position: Named
440+
Default value: False
441+
Accept pipeline input: False
442+
Accept wildcard characters: False
443+
```
444+
438445
### CommonParameters
439446
This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`, `-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`, `-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see [about_CommonParameters](../../Microsoft.PowerShell.Core/about/about_CommonParameters.md).
440447

0 commit comments

Comments
 (0)