Skip to content

Commit 9b2b90a

Browse files
v2.22.0
1 parent 74832fb commit 9b2b90a

File tree

11 files changed

+94
-51
lines changed

11 files changed

+94
-51
lines changed

PSScriptTools.psd1

0 Bytes
Binary file not shown.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,10 @@ Computername Path TotalFiles
441441
BOVINE320 C:\work 1375 137516856
442442
```
443443

444-
The command includes a format file with additional view to display the total size in KB, MB or GB.
444+
The command includes a format file with additional view to display the total size in KB, MB, GB or TB.
445445

446446
```powershell
447-
PS C:\> Get-Childitem D:\ -Directory | Get-FolderSizeInfo -Hidden | Where-Object TotalSize -gt 1gb | Sort-Object TotalSize -Descending | format-table -View gb
447+
PS C:\> Get-ChildItem D:\ -Directory | Get-FolderSizeInfo -Hidden | Where-Object TotalSize -gt 1gb | Sort-Object TotalSize -Descending | format-table -View gb
448448
449449
Computername Path TotalFiles TotalSizeGB
450450
------------ ---- ---------- -----------
@@ -1511,6 +1511,6 @@ If you find this module useful, you might also want to look at my tools for [cre
15111511

15121512
## Compatibility
15131513

1514-
Where possible these commands have been tested with PowerShell 7, but not every platform. If you encounter problems, have suggestions or other feedback, please post an issue. It is assumed you will __not__ be running this commands on any edition of PowerShell Core or any beta releases of PowerShell 7.
1514+
Where possible these commands have been tested with PowerShell 7, but not every platform. If you encounter problems, have suggestions or other feedback, please post an [issue](https://github.com/jdhitsolutions/PSScriptTools/issues). It is assumed you will __not__ be running this commands on any edition of PowerShell Core or any beta releases of PowerShell 7.
15151515

1516-
Last Updated *2020-03-12 15:22:43Z UTC*
1516+
Last Updated *2020-04-17 13:14:01Z UTC*

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log for PSScriptTools
22

3+
## v2.22.0
4+
5+
+ Modified `Set-ConsoleTitle` to move parameter validation into the `Process` script block. (Issue #75)
6+
+ Modified `Get-FolderSizeInfo` to fix an enumeration bug when used in Windows PowerShell. (Issue #77)
7+
+ Added online help links for `Get-GitSize`, `Get-ModuleCommand` and `Remove-MergedBranch`.
8+
+ Updated `foldersizeinfo.format.ps1xml` to include a view called `TB` to display values in TB.
9+
310
## v2.21.0
411

512
+ Updated `Set-ConsoleTitle` and `Set-ConsoleColor` to display a warning if not in a console session. (Issue #75)

docs/Get-FolderSizeInfo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ BOVINE320 D:\logs 134
6767
BOVINE320 D:\2016 5 1.5608
6868
```
6969

70-
Get the top level directories from D and pipe them to Get-FolderSizeInfo. Items with a total size of greater an 1MB are sorted on the total size and then formatted as a table using a built-in view called MB which formats the total size in MB. There is also a view called GB.
70+
Get the top level directories from D and pipe them to Get-FolderSizeInfo. Items with a total size of greater an 1MB are sorted on the total size and then formatted as a table using a built-in view called MB which formats the total size in MB. There are also views named KB,GB and TB to display formatted results accordingly..
7171

7272
### Example 4
7373

docs/Get-GitSize.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: psscripttools
4-
online version:
4+
online version: https://bit.ly/3bj81JZ
55
schema: 2.0.0
66
---
77

@@ -19,10 +19,7 @@ Get-GitSize [[-Path] <String>] [<CommonParameters>]
1919

2020
## DESCRIPTION
2121

22-
When using git, it creates a hidden folder for change tracking.
23-
Because the file is hidden it is easy to overlook how large it might become.
24-
The command uses a formatting file to display a default view.
25-
There is an additonal table view called MB that you can use.
22+
When using git, it creates a hidden folder for change tracking. Because the file is hidden it is easy to overlook how large it might become. The command uses a formatting file to display a default view. There is an additional table view called MB that you can use.
2623

2724
## EXAMPLES
2825

docs/Get-ModuleCommand.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: PSScriptTools
4-
online version:
4+
online version: https://bit.ly/2Kfjm1Q
55
schema: 2.0.0
66
---
77

@@ -27,9 +27,7 @@ Get-ModuleCommand -FullyQualifiedName <ModuleSpecification> [-ListAvailable] [<C
2727

2828
## DESCRIPTION
2929

30-
This is an alternative to Get-Command to make it easier to see at a glance what commands are contained within a module and what they can do.
31-
By default, Get-ModuleCommand looks for loaded modules. Use -ListAvailable to see commands in module not currently loaded.
32-
Note that if the help file is malformed or missing, you might get oddly formatted results.
30+
This is an alternative to Get-Command to make it easier to see at a glance what commands are contained within a module and what they can do. By default, Get-ModuleCommand looks for loaded modules. Use -ListAvailable to see commands in module not currently loaded. Note that if the help file is malformed or missing, you might get oddly formatted results.
3331

3432
## EXAMPLES
3533

docs/Remove-MergedBranch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: psscripttools
4-
online version:
4+
online version: https://bit.ly/3crxxg9
55
schema: 2.0.0
66
---
77

en-us/PSScriptTools-help.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4270,7 +4270,7 @@ BOVINE320 D:\rip 3
42704270
BOVINE320 D:\logs 134 3.9517
42714271
BOVINE320 D:\2016 5 1.5608</dev:code>
42724272
<dev:remarks>
4273-
<maml:para>Get the top level directories from D and pipe them to Get-FolderSizeInfo. Items with a total size of greater an 1MB are sorted on the total size and then formatted as a table using a built-in view called MB which formats the total size in MB. There is also a view called GB.</maml:para>
4273+
<maml:para>Get the top level directories from D and pipe them to Get-FolderSizeInfo. Items with a total size of greater an 1MB are sorted on the total size and then formatted as a table using a built-in view called MB which formats the total size in MB. There are also views named KB,GB and TB to display formatted results accordingly..</maml:para>
42744274
</dev:remarks>
42754275
</command:example>
42764276
<command:example>
@@ -4320,7 +4320,7 @@ sunday 47 24540.6523</dev:code>
43204320
</maml:description>
43214321
</command:details>
43224322
<maml:description>
4323-
<maml:para>When using git, it creates a hidden folder for change tracking. Because the file is hidden it is easy to overlook how large it might become. The command uses a formatting file to display a default view. There is an additonal table view called MB that you can use.</maml:para>
4323+
<maml:para>When using git, it creates a hidden folder for change tracking. Because the file is hidden it is easy to overlook how large it might become. The command uses a formatting file to display a default view. There is an additional table view called MB that you can use.</maml:para>
43244324
</maml:description>
43254325
<command:syntax>
43264326
<command:syntaxItem>
@@ -4419,6 +4419,10 @@ C:\scripts\PSReleaseTools 440 3.0588</dev:code>
44194419
</command:example>
44204420
</command:examples>
44214421
<command:relatedLinks>
4422+
<maml:navigationLink>
4423+
<maml:linkText>Online Version:</maml:linkText>
4424+
<maml:uri>https://bit.ly/3bj81JZ</maml:uri>
4425+
</maml:navigationLink>
44224426
<maml:navigationLink>
44234427
<maml:linkText>Get-ChildItem</maml:linkText>
44244428
<maml:uri></maml:uri>
@@ -4613,6 +4617,10 @@ Synopsis : Ends forcibly the SMB session.
46134617
</command:example>
46144618
</command:examples>
46154619
<command:relatedLinks>
4620+
<maml:navigationLink>
4621+
<maml:linkText>Online Version:</maml:linkText>
4622+
<maml:uri>https://bit.ly/2Kfjm1Q</maml:uri>
4623+
</maml:navigationLink>
46164624
<maml:navigationLink>
46174625
<maml:linkText>Get-Command</maml:linkText>
46184626
<maml:uri></maml:uri>
@@ -9637,6 +9645,10 @@ Deleted branch patch-254 (was 75f6ab8).</dev:code>
96379645
</command:example>
96389646
</command:examples>
96399647
<command:relatedLinks>
9648+
<maml:navigationLink>
9649+
<maml:linkText>Online Version:</maml:linkText>
9650+
<maml:uri>https://bit.ly/3crxxg9</maml:uri>
9651+
</maml:navigationLink>
96409652
<maml:navigationLink>
96419653
<maml:linkText>git.exe</maml:linkText>
96429654
<maml:uri></maml:uri>

formats/foldersizeinfo.format.ps1xml

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
3636
<TableRowEntries>
3737
<TableRowEntry>
3838
<TableColumnItems>
39-
<!--
40-
By default the entries use property names, but you can replace them with scriptblocks.
41-
<ScriptBlock>$_.foo /1mb -as [int]</ScriptBlock>
42-
-->
4339
<TableColumnItem>
4440
<PropertyName>Computername</PropertyName>
4541
</TableColumnItem>
@@ -89,10 +85,6 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
8985
<TableRowEntries>
9086
<TableRowEntry>
9187
<TableColumnItems>
92-
<!--
93-
By default the entries use property names, but you can replace them with scriptblocks.
94-
<ScriptBlock>$_.foo /1mb -as [int]</ScriptBlock>
95-
-->
9688
<TableColumnItem>
9789
<PropertyName>Computername</PropertyName>
9890
</TableColumnItem>
@@ -142,10 +134,6 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
142134
<TableRowEntries>
143135
<TableRowEntry>
144136
<TableColumnItems>
145-
<!--
146-
By default the entries use property names, but you can replace them with scriptblocks.
147-
<ScriptBlock>$_.foo /1mb -as [int]</ScriptBlock>
148-
-->
149137
<TableColumnItem>
150138
<PropertyName>Computername</PropertyName>
151139
</TableColumnItem>
@@ -195,10 +183,6 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
195183
<TableRowEntries>
196184
<TableRowEntry>
197185
<TableColumnItems>
198-
<!--
199-
By default the entries use property names, but you can replace them with scriptblocks.
200-
<ScriptBlock>$_.foo /1mb -as [int]</ScriptBlock>
201-
-->
202186
<TableColumnItem>
203187
<PropertyName>Computername</PropertyName>
204188
</TableColumnItem>
@@ -223,14 +207,6 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
223207
<TypeName>FolderSizeInfo</TypeName>
224208
</ViewSelectedBy>
225209
<GroupBy>
226-
<!--
227-
You can also use a scriptblock to define a custom property name.
228-
You must have a Label tag.
229-
<ScriptBlock>$_.machinename.toUpper()</ScriptBlock>
230-
<Label>Computername</Label>
231-
232-
Use <Label> to set the displayed value.
233-
-->
234210
<ScriptBlock>$(Split-Path $_.Path)</ScriptBlock>
235211
<Label>Path</Label>
236212
</GroupBy>
@@ -255,10 +231,6 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
255231
<TableRowEntries>
256232
<TableRowEntry>
257233
<TableColumnItems>
258-
<!--
259-
By default the entries use property names, but you can replace them with scriptblocks.
260-
<ScriptBlock>$_.foo /1mb -as [int]</ScriptBlock>
261-
-->
262234
<TableColumnItem>
263235
<PropertyName>Name</PropertyName>
264236
</TableColumnItem>
@@ -273,5 +245,54 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
273245
</TableRowEntries>
274246
</TableControl>
275247
</View>
248+
<View>
249+
<!--Created 4/14/2020 by BOVINE320\Jeff-->
250+
<Name>TB</Name>
251+
<ViewSelectedBy>
252+
<TypeName>FolderSizeInfo</TypeName>
253+
</ViewSelectedBy>
254+
<TableControl>
255+
<TableHeaders>
256+
<TableColumnHeader>
257+
<Label>Computername</Label>
258+
<Width>15</Width>
259+
<Alignment>left</Alignment>
260+
</TableColumnHeader>
261+
<TableColumnHeader>
262+
<Label>Path</Label>
263+
<Width>48</Width>
264+
<Alignment>left</Alignment>
265+
</TableColumnHeader>
266+
<TableColumnHeader>
267+
<Label>TotalFiles</Label>
268+
<Width>13</Width>
269+
<Alignment>right</Alignment>
270+
</TableColumnHeader>
271+
<TableColumnHeader>
272+
<Label>TotalSizeTB</Label>
273+
<Width>13</Width>
274+
<Alignment>right</Alignment>
275+
</TableColumnHeader>
276+
</TableHeaders>
277+
<TableRowEntries>
278+
<TableRowEntry>
279+
<TableColumnItems>
280+
<TableColumnItem>
281+
<PropertyName>Computername</PropertyName>
282+
</TableColumnItem>
283+
<TableColumnItem>
284+
<PropertyName>Path</PropertyName>
285+
</TableColumnItem>
286+
<TableColumnItem>
287+
<PropertyName>TotalFiles</PropertyName>
288+
</TableColumnItem>
289+
<TableColumnItem>
290+
<ScriptBlock>[math]::round($_.totalSize /1tb,4)</ScriptBlock>
291+
</TableColumnItem>
292+
</TableColumnItems>
293+
</TableRowEntry>
294+
</TableRowEntries>
295+
</TableControl>
296+
</View>
276297
</ViewDefinitions>
277298
</Configuration>

functions/Get-FolderSizeInfo.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ Function Get-FolderSizeInfo {
139139

140140
If ($files.count -gt 0) {
141141
Write-Verbose "Found $($files.count) files"
142-
$stats = $files | Measure-Object -property length -sum
142+
# there appears to be a bug with the array list in Windows PowerShell
143+
# where it doesn't always properly enumerate. Passing the list
144+
# items via ForEach appears to solve the problem and doesn't
145+
# adversely affect PowerShell 7. Addeed in v2.22.0. JH
146+
$stats = $files.foreach( {$_}) | Measure-Object -property length -sum
143147
$totalFiles = $stats.count
144148
$totalSize = $stats.sum
145149
}

0 commit comments

Comments
 (0)