You've already forked SharedScripts
mirror of
https://github.com/jaapbrasser/SharedScripts.git
synced 2025-12-24 21:51:38 +02:00
Added new script
This commit is contained in:
53
Get-TopFileExtensionSize/Get-TopFileExtensionSize.ps1
Normal file
53
Get-TopFileExtensionSize/Get-TopFileExtensionSize.ps1
Normal file
@@ -0,0 +1,53 @@
|
||||
function Get-TopFileExtensionSize {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Function to retrieve the largest files of a specific extension
|
||||
|
||||
.DESCRIPTION
|
||||
This function retrieves the largest files of a specific extension and list the top X
|
||||
|
||||
.PARAMETER Extension
|
||||
Which extensions will be listed
|
||||
|
||||
.PARAMETER FolderPath
|
||||
The path of a folder or volume that should be enumerated
|
||||
|
||||
.PARAMETER TopFile
|
||||
The top number of files to be displayed for each extension
|
||||
|
||||
.NOTES
|
||||
Name: Get-TopFileExtensionSize
|
||||
Author: Jaap Brasser
|
||||
DateCreated: 2017-10-30
|
||||
Version: 1.0.0
|
||||
Blog: http://www.jaapbrasser.com
|
||||
|
||||
.LINK
|
||||
http://www.jaapbrasser.com
|
||||
|
||||
.EXAMPLE
|
||||
Get-TopFileExtensionSize -Extension 'txt,xml,log' -TopFile 5 -FolderPath C:\
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
#>
|
||||
|
||||
|
||||
param(
|
||||
$Extension = '${P_FileExtensions}',
|
||||
$FolderPath = '${Rtv_DriveLetter}\',
|
||||
$TopFile = '${P_DisplayTopFileExt}'
|
||||
)
|
||||
|
||||
$Extension.Split(',') | ForEach-Object {
|
||||
Get-ChildItem $FolderPath -Include "*$_" -Recurse -ErrorAction SilentlyContinue |
|
||||
Sort-Object -Property Length -Descending |
|
||||
Select-Object -First $TopFile -Property @{
|
||||
Name = 'SizeMB'
|
||||
Expression = {
|
||||
[math]::Round($_.Length/1MB, 2)
|
||||
}
|
||||
}, Name, FullName
|
||||
} | Format-Table -AutoSize
|
||||
}
|
||||
Reference in New Issue
Block a user