How to get the size of the file using Get-ItemProperty in powershell!

Tags:
Powershell
Hi, I have a file having data around 5GB. I tried to get size of the file using get-content $path2 | Measure-Object method. But its taking more time as Get-Content cmdlet is present. Is there method to get the size of this kind of file very quickly. I would like to get the file size using Properties of a file using Get-ItemProperty. Can anyone suggest me on this, Thanks, Dinesh
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Check file size using PowerShell Script in KB, MB or in GB
Below is the PowerShell command to retrieve the file size using PowerShell in KB, MB or in GB format. Here I have a .rar file in the E drive. By using PowerShell we will check the file size of the rar file in KB, MB or in GB.

$file = ‘E:\ProjWork.rar’
Write-Host((Get-Item $file).length/1KB)
Write-Host((Get-Item $file).length/1MB)
Write-Host((Get-Item $file).length/1GB)

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: