File tree Expand file tree Collapse file tree 1 file changed +0
-64
lines changed
Expand file tree Collapse file tree 1 file changed +0
-64
lines changed Original file line number Diff line number Diff line change @@ -1059,67 +1059,3 @@ function Decrypt-AESFileStream {
10591059
10601060}
10611061
1062-
1063-
1064- Function Convert-Size {
1065- <#
1066- .SYSNOPSIS
1067- Converts a size in bytes to its upper most value.
1068-
1069- . DESCRIPTION
1070- Converts a size in bytes to its upper most value.
1071-
1072- . PARAMETER Size
1073- The size in bytes to convert
1074-
1075- . NOTES
1076- Author: Boe Prox
1077- Date Created: 22AUG2012
1078-
1079- . EXAMPLE
1080- Convert-Size -Size 568956
1081- 555 KB
1082-
1083- Description
1084- -----------
1085- Converts the byte value 568956 to upper most value of 555 KB
1086-
1087- . EXAMPLE
1088- Get-ChildItem | ? {! $_.PSIsContainer} | Select -First 5 | Select Name, @{L='Size';E={$_ | Convert-Size}}
1089- Name Size
1090- ---- ----
1091- Data1.cap 14.4 MB
1092- Data2.cap 12.5 MB
1093- Image.iso 5.72 GB
1094- Index.txt 23.9 KB
1095- SomeSite.lnk 1.52 KB
1096- SomeFile.ini 152 bytes
1097-
1098- Description
1099- -----------
1100- Used with Get-ChildItem and custom formatting with Select-Object to list the uppermost size.
1101- #>
1102- [cmdletbinding ()]
1103- Param (
1104- [parameter (ValueFromPipeline = $True , ValueFromPipelineByPropertyName = $True )]
1105- [Alias (" Length" )]
1106- [int64 ]$Size
1107- )
1108- Begin {
1109- If (-Not $ConvertSize ) {
1110- Write-Verbose (" [*] Creating signature from Win32API / Convert size" )
1111- $Signature = @"
1112- [DllImport("Shlwapi.dll", CharSet = CharSet.Auto)]
1113- public static extern long StrFormatByteSize( long fileSize, System.Text.StringBuilder buffer, int bufferSize );
1114- "@
1115- $Global :ConvertSize = [System.Reflection.Assembly ]::LoadWithPartialName(
1116- }
1117- Write-Verbose (" [*] Building buffer for string" )
1118- $stringBuilder = New-Object Text.StringBuilder 1024
1119- }
1120- Process {
1121- Write-Verbose (" Converting {0} to upper most size" -f $Size )
1122- $ConvertSize ::StrFormatByteSize( $Size , $stringBuilder , $stringBuilder.Capacity ) | Out-Null
1123- $stringBuilder.ToString ()
1124- }
1125- }
You can’t perform that action at this time.
0 commit comments