-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_GetItem.ps1
44 lines (41 loc) · 1.07 KB
/
demo_GetItem.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<#
.SYNOPSIS
Gets files and folders (and folder size).
.DESCRIPTION
Long description
.PARAMETER Path
Specifies the path to an item
.EXAMPLE
PS C:\> <example usage>
Explanation of what the example does
.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
.NOTES
General notes
#>
function Get-ItemPlus {
[CmdletBinding()]
param (
# Parameter help description
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[String[]]
$Path
)
begin {
Write-Verbose "Begin Block"
}
process {
Write-Verbose "Process Block"
foreach ($item in $Path) {
$itemInfo = Get-Item -Path $item
$duResult = C:\Tools\SysInternalsSuite\du.exe $item -nobanner 2>$null
$sizeInBytes = [int64] $duResult[2].Substring(0,$duResult[2].IndexOf(' bytes')).Substring('Size: '.Length)
Add-Member -InputObject $itemInfo -NotePropertyName 'SizeInBytes' -NotePropertyValue $sizeInBytes -PassThru
}
}
end {
Write-Verbose "End Block"
}
}