external help file | Module Name | online version | schema |
---|---|---|---|
PSTree.dll-Help.xml |
PSTree |
2.0.0 |
tree
like cmdlet for PowerShell.
Get-PSTree
[[-Path] <String[]>]
[-Depth <UInt32>]
[-Recurse]
[-Force]
[-Directory]
[-RecursiveSize]
[-Exclude <String[]>]
[-Include <String[]>]
[<CommonParameters>]
Get-PSTree
[-LiteralPath <String[]>]
[-Depth <UInt32>]
[-Recurse]
[-Force]
[-Directory]
[-RecursiveSize]
[-Exclude <String[]>]
[-Include <String[]>]
[<CommonParameters>]
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.
PS ..\PSTree> Get-PSTree
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.
PS ..\PSTree> Get-PSTree $HOME -Directory -Recurse
In this example $HOME
is bound positionally to the -Path
parameter.
Example 3: Get the $HOME
tree 2 levels deep displaying hidden files and folders
PS ..\PSTree> Get-PSTree -Depth 2 -Force
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.
Example 4: Get the C:\
drive tree 2 levels in depth displaying only folders calculating the recursive size
PS ..\PSTree> Get-PSTree C:\ -Depth 2 -RecursiveSize -Directory
PS ..\PSTree> Get-PSTree $HOME -Recurse -Exclude *.jpg, *.png
The -Exclude
parameter supports wildcard patterns, exclusion patterns are tested against the items .FullName
property. Excluded items do not do not add to the folders size.
PS ..\PSTree> Get-ChildItem -Directory | Get-PSTree
DirectoryInfo
and FileInfo
instances having the PSPath
Property are bound to the -LiteralPath
parameter.
PS ..\PSTree> Get-ChildItem -Directory | Get-PSTree -Include *.ps1
Similar to -Exclude
, the -Include
parameter supports wildcard patterns, however, this parameter works only with Files.
Determines the number of subdirectory levels that are included in the recursion.
Type: UInt32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 3
Accept pipeline input: False
Accept wildcard characters: False
Use this switch to display Directories only.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specifies an array of one or more string patterns to be matched as the cmdlet gets child items. Any matching item is excluded from the output. Wildcard characters are accepted.
Excluded items do not add to the recursive folders size.
Note
- Patterns are tested against the object's
.FullName
property. - The
-Include
and-Exclude
parameters can be used together and the inclusions are applied after the exclusions.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Gets items that otherwise can't be accessed by the user, such as hidden or system files.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specifies an array of one or more string patterns to be matched as the cmdlet gets child items. Any matching item is included in the output. Wildcard characters are accepted.
Note
- Patterns are tested against the object's
.FullName
property. - This parameter focuses only on files, the inclusion patterns are only evaluated against
FileInfo
instances. - The
-Include
and-Exclude
parameters can be used together and the inclusions are applied after the exclusions.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Absolute or relative folder path. Note that the value is used exactly as it's typed. No characters are interpreted as wildcards.
Type: String[]
Parameter Sets: LiteralPath
Aliases: PSPath
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies a path to one or more locations. Wildcards are accepted. The default location is the current directory (.
).
Type: String[]
Parameter Sets: Path
Aliases:
Required: False
Position: 0
Default value: Current directory
Accept pipeline input: True (ByValue)
Accept wildcard characters: True
Gets the items in the specified location and in all child items of the location.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This switch enables the cmdlet to calculate the recursive size of folders in a hierarchy. By default, the cmdlet only displays the size of folders based on the sum of the file's Length in each directory. 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.
By default, the size of hidden and system items is not added to the recursive size, for this you must use the -Force
parameter.
Excluded items with the -Exclude
parameter do not add to the recursive size.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters. For more information, see about_CommonParameters.
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.