Skip to content

Commit 5a2df36

Browse files
committed
updates docs
1 parent 98d8a2a commit 5a2df36

File tree

3 files changed

+74
-88
lines changed

3 files changed

+74
-88
lines changed

docs/en-US/Get-PSTree.md

Lines changed: 65 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ schema: 2.0.0
99

1010
## SYNOPSIS
1111

12-
`tree` like cmdlet for PowerShell.
12+
A PowerShell cmdlet that displays a hierarchical, tree-like view of folder contents, including folder size calculations, inspired by the classic `tree` command.
1313

1414
## SYNTAX
1515

@@ -45,75 +45,85 @@ Get-PSTree
4545

4646
## DESCRIPTION
4747

48-
`Get-PSTree` is a PowerShell cmdlet that intends to emulate the `tree` command with added functionalities to calculate the folders size as well as recursive folders size.
48+
The `Get-PSTree` cmdlet offers a tree-style visualization of a folder's contents, drawing inspiration from the classic `tree` command. It displays the file system hierarchy, including directories and files, with enhanced functionality to calculate folder sizes—both individual and recursive—making it ideal for analyzing disk usage and organizing file structures. This cmdlet supports filtering by depth and enabling recursive traversal, enabling efficient exploration of file systems on any supported platform. Use it to identify large folders, manage directory layouts, or gain insights into file system organization.
4949

5050
## EXAMPLES
5151

52-
### Example 1: Get the current directory tree with default parameters values
52+
### Example 1: Get the current Directory Tree with Default Parameters
5353

5454
```powershell
5555
PS ..\PSTree> Get-PSTree
5656
```
5757

58-
The default parameter set uses `-Depth` with a value of 3. No hidden and system files folder are displayed and recursive folder size is not calculated.
58+
This example retrieves the directory and file structure of the current directory, using the default parameters: __a depth of 3 levels__ and no recursive traversal beyond that limit. It displays both directories and files, including their sizes, but does not include hidden or system items unless explicitly requested through other means.
5959

60-
### Example 2: Get the `$HOME` tree recursively displaying only folders
60+
### Example 2: Display the `$HOME` Directory Tree Recursively, Showing Only Directories
6161

6262
```powershell
6363
PS ..\PSTree> Get-PSTree $HOME -Directory -Recurse
6464
```
6565

66-
In this example `$HOME` is bound positionally to the `-Path` parameter.
66+
This example retrieves the complete directory hierarchy under the `$HOME` path, traversing all subfolders recursively and displaying only directories (excluding files).
6767

68-
### Example 3: Get the `$HOME` tree 2 levels deep displaying hidden files and folders
68+
### Example 3: Display the `$HOME` Directory Tree, Limited to 2 Levels, Including Hidden Items
6969

7070
```powershell
71-
PS ..\PSTree> Get-PSTree -Depth 2 -Force
71+
PS ..\PSTree> Get-PSTree $HOME -Depth 2 -Force
7272
```
7373

7474
> [!TIP]
75-
> The `-Force` switch is needed to display hidden files and folders. In addition, hidden child items do not add up to the folders size without this switch.
75+
> The `-Force` switch is required to include hidden files and folders in the output. Additionally, hidden items contribute to folder sizes (including recursive sizes with [`-RecursiveSize`](#-recursivesize), if specified), ensuring a comprehensive view of disk usage.
7676
77-
### Example 4: Get the `C:\` drive tree 2 levels in depth displaying only folders calculating the recursive size
77+
### Example 4: Display the `C:\` Drive Tree, Limited to 2 Levels, Showing Only Directories with Recursive Sizes
7878

7979
```powershell
8080
PS ..\PSTree> Get-PSTree C:\ -Depth 2 -RecursiveSize -Directory
8181
```
8282

83-
### Example 5: Get the `$HOME` tree recursively excluding all `.jpg` and `.png` files
83+
This example retrieves the directory structure under the `C:\` drive, limited to 2 levels of depth, displaying only directories (excluding files) and calculating their recursive sizes. It provides a controlled view for analyzing disk usage, summing the sizes of all files within each directory and its subdirectories.
84+
85+
### Example 5: Display the `$HOME` Directory Tree Recursively, Excluding `.jpg` and `.png` Files
8486

8587
```powershell
8688
PS ..\PSTree> Get-PSTree $HOME -Recurse -Exclude *.jpg, *.png
8789
```
8890

8991
> [!NOTE]
9092
>
91-
> - The `-Exclude` parameter supports [wildcard patterns](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.3), exclusion patterns are evaluated using the items `.Name` property.
92-
> - __Excluded items do not do not add to the folders size.__
93+
> - The `-Exclude` parameter supports [wildcard patterns](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.3), and patterns are evaluated using the items’ `.Name` property.
94+
> - Excluded items, such as `.jpg` and `.png` files in this case, do not contribute to folder sizes, including recursive sizes calculated by [`-RecursiveSize`](#-recursivesize).
95+
96+
This example retrieves the complete directory and file hierarchy under the `$HOME` path, traversing all subfolders recursively, while excluding files matching the patterns `*.jpg` and `*.png`. It displays remaining directories and files with their sizes, useful for focusing on specific file types or managing disk space.
9397

94-
### Example 6: Get the tree of all folders in a location
98+
### Example 6: Display the Tree of All Directories in the Current Location
9599

96100
```powershell
97101
PS ..\PSTree> Get-ChildItem -Directory | Get-PSTree
98102
```
99103

100104
> [!TIP]
101-
> Output from `Get-ChildItem` can be piped to this cmdlet. Pipeline input is bound to `-LiteralPath` parameter if the items have a `PSPath` property.
105+
> Output from cmdlets that work with the file system and return `System.IO.FileSystemInfo` objects (e.g., `Get-ChildItem`, `Get-Item`) can be piped to `Get-PSTree`. Pipeline input is bound to the `-LiteralPath` parameter if the objects have a `PSPath` property, enabling seamless traversal of multiple directory structures with default settings (depth of 3, no recursion unless specified).
102106
103-
### Example 7: Get the tree of all folders in a location including only `*.ps1` files
107+
This example pipes the output of `Get-ChildItem` to `Get-PSTree`, retrieving the directory and file structure for each directory in the current location. It displays hierarchies with default depth (3 levels) and folder sizes, excluding hidden or system items unless [`-Force`](#-force) is used.
108+
109+
### Example 7: Display the Tree of All Directories in the Current Location, Including Only `.ps1` Files
104110

105111
```powershell
106112
PS ..\PSTree> Get-ChildItem -Directory | Get-PSTree -Include *.ps1
107113
```
108114

109115
> [!IMPORTANT]
110-
> Similar to `-Exclude`, the `-Include` parameter supports [wildcard patterns](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.3), however, __this parameter works only with Files__.
116+
>
117+
> - Similar to `-Exclude`, the `-Include` parameter supports [wildcard patterns](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.3), __but it applies only to files, not directories__.
118+
> - Only files matching the pattern (e.g., `*.ps1`) are included in the output, while directories are always shown to maintain the hierarchy.
119+
120+
This example pipes the output of `Get-ChildItem` to `Get-PSTree`, retrieving the directory structure for each directory in the current location, but including only `.ps1` files within those directories. It displays the hierarchy with default depth (3 levels) and folder sizes, useful for focusing on PowerShell scripts while preserving directory context.
111121

112122
## PARAMETERS
113123

114124
### -Depth
115125

116-
Determines the number of subdirectory levels that are included in the recursion. Default value is 3.
126+
Specifies the maximum depth of the folder traversal. The default value is 3, limiting the hierarchy to three levels. Use this parameter to control the depth for performance or readability when exploring large directory structures.
117127

118128
```yaml
119129
Type: Int32
@@ -129,7 +139,7 @@ Accept wildcard characters: False
129139
130140
### -Directory
131141
132-
Use this switch to display Directories only.
142+
Limits output to directories only, excluding files. When specified, the cmdlet displays only `TreeDirectory` objects, omitting `TreeFile` objects, for a focused view of folder hierarchies.
133143

134144
```yaml
135145
Type: SwitchParameter
@@ -145,16 +155,12 @@ Accept wildcard characters: False
145155

146156
### -Exclude
147157

148-
Specifies an array of one or more string patterns to be matched as the cmdlet gets child items.
149-
Any matching item is excluded from the output.
150-
Wildcard characters are accepted.
151-
152-
Excluded items do not add to the recursive folders size.
158+
Specifies an array of one or more string patterns to exclude items from the output as the cmdlet traverses the folder structure. Matching items are omitted from the results. [Wildcard characters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.5) are accepted.
153159

154160
> [!NOTE]
155161
>
156-
> - Patterns are evaluated using the object's `.Name` property.
157-
> - The `-Include` and `-Exclude` parameters can be used together, however the exclusions are applied before the inclusions.
162+
> - Patterns are evaluated against the `.Name` property of each item.
163+
> - The `-Include` and `-Exclude` parameters can be used together, but exclusions are applied before inclusions.
158164

159165
```yaml
160166
Type: String[]
@@ -170,7 +176,7 @@ Accept wildcard characters: True
170176

171177
### -Force
172178

173-
Gets items that otherwise can't be accessed by the user, such as hidden or system files.
179+
Allows the cmdlet to access items that would otherwise be inaccessible, such as hidden or system files and folders. When specified, hidden and system items are included in the output and contribute to recursive folder sizes calculated by [`-RecursiveSize`](#-recursivesize).
174180

175181
```yaml
176182
Type: SwitchParameter
@@ -186,15 +192,13 @@ Accept wildcard characters: False
186192

187193
### -Include
188194

189-
Specifies an array of one or more string patterns to be matched as the cmdlet gets child items.
190-
Any matching item is included in the output.
191-
Wildcard characters are accepted.
195+
Specifies an array of one or more string patterns to include only matching items in the output as the cmdlet traverses the folder structure. Matching items are included, while others are omitted. [Wildcard characters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.5) are accepted.
192196

193197
> [!NOTE]
194198
>
195-
> - __This parameter works only on files.__
196-
> - Patterns are evaluated using the object's `.Name` property.
197-
> - The `-Include` and `-Exclude` parameters can be used together, however the exclusions are applied before the inclusions.
199+
> - __This parameter works only on files, not directories.__
200+
> - Patterns are evaluated against the `.Name` property of each item.
201+
> - The `-Include` and `-Exclude` parameters can be used together, but exclusions are applied before inclusions.
198202

199203
```yaml
200204
Type: String[]
@@ -210,9 +214,7 @@ Accept wildcard characters: True
210214

211215
### -LiteralPath
212216

213-
Absolute or relative folder path.
214-
Note that the value is used exactly as it's typed.
215-
No characters are interpreted as wildcards.
217+
Specifies the literal path to the folder to traverse, without interpreting wildcard characters. This parameter accepts an array of paths and can receive input from the pipeline by property name (using the `PSPath` alias). Use this for exact path matching, bypassing wildcard expansion.
216218

217219
```yaml
218220
Type: String[]
@@ -228,8 +230,7 @@ Accept wildcard characters: False
228230

229231
### -Path
230232

231-
Specifies a path to one or more locations. Wildcards are accepted.
232-
The default location is the current directory (`$PWD`).
233+
Specifies the path to one or more folders to traverse. Accepts an array of paths, which can include [wildcard characters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.5). The default location is the current directory (`$PWD`) if no path is provided.
233234

234235
```yaml
235236
Type: String[]
@@ -245,7 +246,7 @@ Accept wildcard characters: True
245246

246247
### -Recurse
247248

248-
Gets the items in the specified location and in all child items of the location.
249+
Enables recursive traversal of all subfolders under the specified path. Use this switch to explore the complete folder hierarchy, but note that it may impact performance on large directories—consider ][`-Depth`](#-depth) for smaller subsets.
249250

250251
```yaml
251252
Type: SwitchParameter
@@ -261,12 +262,9 @@ Accept wildcard characters: False
261262

262263
### -RecursiveSize
263264

264-
This switch enables the cmdlet to calculate the recursive size of folders in a hierarchy.
265-
By default, the cmdlet only displays the size of folders based on the sum of the file's Length in each directory.
266-
It's important to note that this is a more expensive operation, in order to calculate the recursive size, all items in the hierarchy needs to be traversed.
265+
Enables the cmdlet to calculate the recursive size of folders across the entire hierarchy, summing the sizes of all files within each directory and its subdirectories. By default, the cmdlet calculates only the size of files directly within each directory. This is a more resource-intensive operation, as it requires traversing all items in the hierarchy.
267266

268-
By default, the size of hidden and system items is not added to the recursive size, for this you must use the `-Force` parameter.
269-
Excluded items with the `-Exclude` parameter do not add to the recursive size.
267+
By default, hidden and system items are excluded from recursive size calculations unless [`-Force`](#-force) is specified. Items excluded by the [`-Exclude`](#-exclude) parameter do not contribute to recursive sizes.
270268

271269
```yaml
272270
Type: SwitchParameter
@@ -286,12 +284,31 @@ This cmdlet supports the common parameters. For more information, see [about_Com
286284

287285
## INPUTS
288286

289-
### String
287+
### System.String
290288

291-
You can pipe a string that contains a path to this cmdlet. Output from `Get-Item` and `Get-ChildItem` can be piped to this cmdlet.
289+
You can pipe a strings containing file system paths to this cmdlet.
290+
Output from cmdlets that return `System.IO.FileSystemInfo` objects (e.g., `Get-Item`, `Get-ChildItem`) can be piped to this cmdlet, with pipeline input bound to `-LiteralPath` if the objects have a `PSPath` property.
292291

293292
## OUTPUTS
294293

295-
### TreeDirectory
294+
### PSTree.TreeDirectory
295+
296+
Returns objects of type `TreeDirectory` representing directories in a hierarchical structure, with `TreeFile` objects included as children. Each `TreeDirectory` object includes properties such as `Name`, `FullName`, `Size`, and `Depth`, reflecting the file system organization and enabling size-based analysis. This prioritizes directories as the primary output type for tree navigation, with files nested within for comprehensive exploration.
297+
298+
### PSTree.TreeFile
299+
300+
Returns objects of type `TreeFile` representing files within directories, included in the output unless the `-Directory` parameter is specified. Each object includes properties such as `Name`, `FullName`, `Size`, and `Depth`, allowing detailed file analysis within the hierarchical structure. These objects are nested under `TreeDirectory` objects, supporting disk usage tracking and file system navigation.
301+
302+
## NOTES
303+
304+
This cmdlet requires PowerShell 5.1 or later and supports cross-platform file system exploration on Windows, Linux, and macOS. It may require elevated permissions for certain system folders. Use `-Recurse` or `-RecursiveSize` cautiously with large directories to avoid performance issues, and refer to the [`about_TreeStyle`](./about_TreeStyle.md) help topic for customizing the output format. For Windows-specific registry navigation, see the [`Get-PSTreeRegistry`](./Get-PSTreeRegistry.md) cmdlet
305+
306+
## RELATED LINKS
307+
308+
[__tree Command__](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tree)
309+
310+
[__`about_TreeStyle`__](./about_TreeStyle.md)
311+
312+
[__`Get-PSTree` Source__](../../src/PSTree/Commands/GetPSTreeCommand.cs)
296313

297-
### TreeFile
314+
[__`Get-PSTree` Tests__](../../tests/GetPSTreeCommand.tests.ps1)

docs/en-US/Get-PSTreeRegistry.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ This example uses the registry provider path to explore all keys under `HKEY_USE
100100

101101
### -Depth
102102

103-
Specifies the maximum depth of the registry traversal. Default value is 3.
103+
Specifies the maximum depth of the registry traversal. Default value is 3. Use this parameter to control the depth for performance or readability when exploring large registry hives.
104104

105105
```yaml
106106
Type: Int32
@@ -132,7 +132,7 @@ Accept wildcard characters: False
132132

133133
### -LiteralPath
134134

135-
Specifies the literal registry paths to traverse, without wildcard expansion. This parameter is mandatory and accepts input from the pipeline by property name (using the `PSPath` alias). Use this for exact path matching, bypassing wildcard interpretation.
135+
Specifies the literal registry paths to traverse, without wildcard expansion. This parameter accepts input from the pipeline by property name (using the `PSPath` alias). Use this for exact path matching, bypassing wildcard interpretation.
136136

137137
> [!TIP]
138138
> For registry base keys not mapped as PowerShell drives (e.g., `HKCU:\` and `HKLM:\`), you can use the provider path format by prefixing the path with `Registry::`. For example, to traverse all keys under `HKEY_USERS` exactly as specified, use: `Get-PSTreeRegistry -LiteralPath Registry::HKEY_USERS`.
@@ -151,7 +151,7 @@ Accept wildcard characters: False
151151

152152
### -Path
153153

154-
Specifies the registry paths to traverse. Accepts one or more registry paths (e.g., `HKLM:\Software`, `HKCU:\Software`), which can include wildcards. This parameter is mandatory and can accept input from the pipeline. Paths are resolved using PowerShell's registry provider.
154+
Specifies the registry paths to traverse. Accepts one or more registry paths (e.g., `HKLM:\Software`, `HKCU:\Software`), which can include [wildcard characters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.5). This parameter can accept input from the pipeline. Paths are resolved using [PowerShell's registry provider](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_registry_provider?view=powershell-7.5).
155155

156156
> [!TIP]
157157
> For registry base keys not mapped as PowerShell drives (e.g., `HKCU:\` and `HKLM:\`), you can use the provider path format by prefixing the path with `Registry::`. For example, to traverse each key under `HKEY_USERS`, use: `Get-PSTreeRegistry -Path Registry::HKEY_USERS\*`.
@@ -163,7 +163,7 @@ Aliases:
163163
164164
Required: False
165165
Position: 0
166-
Default value: None
166+
Default value: $PWD
167167
Accept pipeline input: True (ByValue)
168168
Accept wildcard characters: True
169169
```
@@ -193,7 +193,7 @@ This cmdlet supports the common parameters. For more information, see [about_Com
193193
### System.String
194194

195195
You can pipe strings containing registry paths to this cmdlet.
196-
Output from `Get-Item` and `Get-ChildItem` can be piped to this cmdlet.
196+
Output from cmdlets that return `Microsoft.Win32.RegistryKey` objects (e.g., `Get-Item`, `Get-ChildItem`) can be piped to this cmdlet, with pipeline input bound to `-LiteralPath` if the objects have a `PSPath` property.
197197

198198
## OUTPUTS
199199

@@ -207,15 +207,14 @@ Returns objects of type `TreeRegistryValue` representing registry values associa
207207

208208
## NOTES
209209

210-
This cmdlet is Windows-only and requires PowerShell 5.1 or later. It may require elevated permissions for certain registry hives.
210+
This cmdlet is Windows-only and requires PowerShell 5.1 or later. It may require elevated permissions for certain registry hives. For file system navigation, see the [`Get-PSTree`](./Get-PSTree.md) cmdlet.
211211

212212
## RELATED LINKS
213213

214214
[**Microsoft.Win32 Namespace**](https://learn.microsoft.com/en-us/dotnet/api/microsoft.win32?view=net-9.0)
215215

216216
[**about_Registry_Provider**](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_registry_provider?view=powershell-7.5)
217217

218-
[**`Get-PSTreeRegistry` Source Code**](../../src/PSTree/Commands/GetPSTreeRegistryCommand.cs)
219-
218+
[**`Get-PSTreeRegistry` Source**](../../src/PSTree/Commands/GetPSTreeRegistryCommand.cs)
220219

221220
[**`Get-PSTreeRegistry` Tests**](../../tests/GetPSTreeRegistryCommand.tests.ps1)

0 commit comments

Comments
 (0)