Skip to content

Commit 5c09464

Browse files
v2.15.1
1 parent 81978ed commit 5c09464

7 files changed

Lines changed: 63 additions & 11 deletions

File tree

PSScriptTools.psd1

0 Bytes
Binary file not shown.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ Use this command to clean and optimize content from text files. Sometimes text f
321321

322322
This command will strip out any lines that are blank or have nothing by white space, and trim leading and trailing spaces. The optimized text is then written back to the pipeline. Optionally, you can specify a property name. This can be useful when your text file is a list of computer names and you want to take advantage of pipeline binding.
323323

324-
### [Get-FileItem](./Get-FileItem.md)
324+
### [Get-FileItem](docs/Get-FileItem.md)
325325

326326
A PowerShell version of the CLI `where.exe` command. You can search with a simple or regex pattern.
327327

@@ -1147,4 +1147,4 @@ You will need to manually install the file.
11471147

11481148
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.
11491149

1150-
Last Updated *2020-01-29 20:06:54Z UTC*
1150+
Last Updated *2020-01-30 16:49:22Z UTC*

changelog.md

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

3+
## v2.15.1
4+
5+
+ Fixed bug in `Get-FolderSizeInfo` that was returning incorrect data (Issue #60)
6+
+ Updated newer help with online links
7+
+ Updated `README.md`
8+
39
## v2.15.0
410

511
+ Added `Get-FolderSizeInfo` and its alias `gsi` along with a corresponding format.ps1xml file.

docs/Get-FolderSizeInfo.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: http://bit.ly/2RCoWQ6
55
schema: 2.0.0
66
---
77

docs/Test-IsPSWindows.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: http://bit.ly/2GBPriA
55
schema: 2.0.0
66
---
77

en-us/PSScriptTools-help.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4275,6 +4275,10 @@ BOVINE320 D:\2016 5
42754275
</command:example>
42764276
</command:examples>
42774277
<command:relatedLinks>
4278+
<maml:navigationLink>
4279+
<maml:linkText>Online Version:</maml:linkText>
4280+
<maml:uri>http://bit.ly/2RCoWQ6</maml:uri>
4281+
</maml:navigationLink>
42784282
<maml:navigationLink>
42794283
<maml:linkText>Get-Childitem</maml:linkText>
42804284
<maml:uri></maml:uri>
@@ -11382,7 +11386,12 @@ True</dev:code>
1138211386
</dev:remarks>
1138311387
</command:example>
1138411388
</command:examples>
11385-
<command:relatedLinks />
11389+
<command:relatedLinks>
11390+
<maml:navigationLink>
11391+
<maml:linkText>Online Version:</maml:linkText>
11392+
<maml:uri>http://bit.ly/2GBPriA</maml:uri>
11393+
</maml:navigationLink>
11394+
</command:relatedLinks>
1138611395
</command:command>
1138711396
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
1138811397
<command:details>

functions/Get-FolderSizeInfo.ps1

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,56 @@ Function Get-FolderSizeInfo {
2222

2323
Process {
2424
foreach ($item in $path) {
25-
Write-Verbose "Measuring $item on $([System.Environment]::MachineName)"
26-
2725
$cPath = (Convert-Path $item)
26+
Write-Verbose "Measuring $cPath on $([System.Environment]::MachineName)"
27+
2828
if (Test-Path $cPath) {
2929

3030
$d = [System.IO.DirectoryInfo]::new($cPath)
3131

32-
if ($hidden) {
33-
$files = $d.GetFiles("*", "AllDirectories")
34-
}
32+
If ($psversiontable.psversion.major -gt 5 ) {
33+
#this .NET class is not available in Windows PowerShell 5.1
34+
$opt = [System.IO.EnumerationOptions]::new()
35+
$opt.RecurseSubdirectories = $True
36+
37+
if ($hidden) {
38+
Write-Verbose "Including hidden files"
39+
$opt.AttributesToSkip = "SparseFile", "ReparsePoint"
40+
}
41+
42+
$files = $d.GetFiles("*",$opt)
43+
} #if newer that Windows PowerShell 5.1
3544
else {
36-
$files = $d.GetFiles()
45+
Write-Verbose "Using legacy code"
46+
if ($hidden) {
47+
Write-Verbose "Including hidden files"
48+
$files = $d.GetFiles("*","AllDirectories")
49+
}
50+
else {
51+
52+
$files = ($d.GetFiles()).Where({$_.attributes -notmatch "hidden"})
53+
#a function to recurse and get all non-hidden directories
54+
Function _enumdir {
55+
[cmdletbinding()]
56+
Param([string]$Path)
57+
# write-host $path -ForegroundColor cyan
58+
$di = [System.IO.DirectoryInfo]::new($path)
59+
$top = ($di.GetDirectories()).Where({$_.attributes -notmatch "hidden"})
60+
$top
61+
foreach ($t in $top) {
62+
_enumdir $t.fullname
63+
}
64+
}
65+
#get a list of all non-hidden subfolders
66+
Write-Verbose "Getting non-hidden subfolders"
67+
$all = _enumdir $cpath
68+
#get the files in each subfolder
69+
Write-Verbose "Getting files from subfolders"
70+
($all).Foreach({ $files+= ([System.IO.DirectoryInfo]"$($_.fullname)").GetFiles() | where-object {$_.Attributes -notmatch "Hidden"}})
71+
} #get non-hidden files
3772
}
73+
74+
Write-Verbose "Found $($files.count) files"
3875
$stats = $files | Measure-Object -property length -sum
3976

4077
[pscustomobject]@{

0 commit comments

Comments
 (0)