Last active
December 13, 2022 23:58
-
-
Save gravejester/ddc31e8feee2fbd1b379 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Update-FileInfoType { | |
<# | |
Update FileInfo type to include SizeOnDisk | |
Author: Øyvind Kallstad | |
#> | |
$typeData = Get-TypeData System.IO.FileInfo | |
$scriptBlock = { | |
$blockSize = $this.PSDrive.BlockSize | |
$size = $this.Length | |
[math]::Ceiling($size/$blockSize) * $blockSize | |
} | |
$scriptProperty = New-Object System.Management.Automation.Runspaces.ScriptPropertyData 'SizeOnDisk', $scriptBlock | |
if (-not($typeData.Members['SizeOnDisk'])) { | |
$typeData.Members.Add('SizeOnDisk', $scriptProperty) | |
} | |
Update-TypeData $typeData -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment