Get-DirectoryStats: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) K |
||
Zeile 1: | Zeile 1: | ||
− | + | ''Get the directory size of a local or an remote sytem.'' | |
+ | |||
<source lang="PowerShell"> | <source lang="PowerShell"> |
Version vom 20. Februar 2020, 20:00 Uhr
Get the directory size of a local or an remote sytem.
Function Get-DirectoryStats { param( [Parameter(Position=0)] [string] $Path = (PWD).path ) process{ $Folders = Get-ChildItem $Path -Directory | Sort-Object foreach ($Folder in $Folders) { $subFolderItems = Get-ChildItem $Folder.FullName -File -Recurse -Force | Measure-Object -Property Length -Sum | Select-Object Sum $Size = [math]::Round($subFolderItems.sum/1GB,2) [PSCustomObject]@{ Size = $Size DirectoryName = $Folder.Name FullPath = $Folder.FullName } } } }