Last active
October 12, 2015 01:14
-
-
Save martin9700/d325b61f06071130e3f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cls | |
Write-Verbose "$(Get-Date): Getting DIR information..." -Verbose | |
$Dir = "C:\dropbox\test" | |
$Files = Get-ChildItem $Dir -File -Recurse | Select FullName,BaseName,Length | |
Write-Verbose "$(Get-Date): $($Files.Count) files found" -Verbose | |
Write-Verbose "$(Get-Date): Using calculated fields in Select..." -Verbose | |
Measure-Command { | |
$Files | Select Fullname,BaseName,Length,@{Name="SizeMB";Expression={ [math]::Round($_.Length / 1MB,2) }},@{Name="SizeGB";Expression={ [math]::Round($_.Length / 1GB,2) }} | |
} | |
Write-Verbose "$(Get-Date): Now calculating with dynamic properties..." -Verbose | |
Measure-Command { | |
$Files | | |
Add-Member -MemberType ScriptProperty -Name SizeMB -Value { [math]::Round($this.Length / 1MB,2) } -PassThru | | |
Add-Member -MemberType ScriptProperty -Name SizeGB -Value { [math]::Round($this.Length / 1GB,2) } | |
$Files | |
} | |
Write-Verbose "$(Get-Date): Done!" -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment