< Back

Get-LongDirectorySize

Sun Jan 19, 2020 5:59 pm

NAME Get-LongDirectorySize



SYNOPSIS

Gets the size of a directory without following any symbolic links or mount points.





SYNTAX

Get-LongDirectorySize [-Path] <String> [-Recurse <SwitchParameter>] [-ContinueonError <SwitchParameter>]

[<CommonParameters>]





DESCRIPTION

Properties include aggregated size of a folder along with some additional properties such as: Directory File

Hidden Count

Total: is the total number of enumerated objects.

Directory: is the total number of folders.

File: is the total number of files. File is considered when object is neither Directory nor ReparsePoint.

Size: is the total size(bytes) of enumerated objects.

Count: the total number of Files + folders in a given folder.





PARAMETERS

-Path <String>

The target directory.This value can be a relative or an aboslute path



Required? true

Position? 0

Default value CurrentDirectory

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-Recurse [<SwitchParameter>]

Enumerates files and folders in sub-directories



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ContinueonError [<SwitchParameter>]

Suppress any Exception that might be thrown as a result from a failure, such as ACLs protected directories or

non-accessible reparse points.

Note: using this switch might result in an incorrect directory size.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Unit [<String>]

Specify the unit type for folder size : ('KB', 'MB', 'GB', 'TB', 'PB', 'Bytes' )



Required? false

Position? named

Default value bytes

Accept pipeline input? false

Accept wildcard characters? false



-IncludeSubfolder [<Switch>]

Specify this parameter to list the sizes of the subfolders including the parent



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String







OUTPUTS

PSObject







-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-LongDirectorySize -Path c:\\temp



Path Size Directory File Hidden Count

---- ---- --------- ---- ------ -----

c:\\temp 49337903 35 67 0 102



Gets the directory statistics for c:\\temp. Since the Unit size parameter was not specified the size of the folder

is in "bytes".

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-LongDirectorySize -Path c:\\temp -Recurse





-ContinueonError



Path Size Directory File Hidden Count





c:\\temp 7855289946 2084 4978 18 7062



List the aggregate size of all the files and folders in the temp directory, and will ignore any exceptions\\errors

that may arise due to access or other issues.

Warning: using the -ContinueonError may result in an incorrect directory size.

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-LongDirectorySize -Path c:\\temp -Recurse -IncludeSubfolder -Unit MB



Path Size Directory File Hidden Count



c:\\temp 7491 2084 4978 18 7062



c:\\temp\\.vscode 0 0 2 0 2



c:\\temp\\123 0 3 0 0 3



c:\\temp\\234 0 2 1 0 3



c:\\temp\\alpha1 1 4 7 0 11



Recursively list the total size of the temp folder along with the sizes of all the subfolders. The size of the

folders are calulated in megabytes.



RELATED LINKS

Link 1 http://alphafs.alphaleonis.com/doc/2.1/ ... F3D4B6.htm