
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the folder size using PowerShell?
We will first retrieve the content of the folder using the Get-ChildItem command and then pipeline the Measure-Object command as shown below.
Get-ChildItem C:\Temp\ -Recurse | Measure-Object -Property Length -Sum
Output
Count : 1514 Average : Sum : 372060503 Maximum : Minimum : Property : Length
So the above output shows that there is a total of 1514 files and folders and the sum shows the size of all the files and folders combined in KB. We can convert it to the MB as shown below.
(Get-ChildItem C:\Temp\ -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB 354.824545860291
We can get the round figure,
[Math]::Round( ((Get-ChildItem C:\Temp\ -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB),2 ) 354.82
You can check the same on the folder path.
- Related Questions & Answers
- How to get the Shared folder permissions with PowerShell?
- How to calculate the size of folder using Java?
- How to calculate the Size of Folder using C#?
- How to share a windows folder using PowerShell?
- How to remove windows folder sharing using PowerShell?
- How to get the Azure VM Size using Azure CLI in PowerShell?
- How to get the available azure VM size using Azure CLI in PowerShell?
- How to change SMB shared folder access permission using PowerShell?
- How to change the size of the Console using PowerShell?
- How to get the directories (only) from a folder using Java?
- How to view folder NTFS permission with PowerShell?
- How to change the size of the Azure VM using PowerShell?
- How to get the disk information using PowerShell?
- How to get the disk performance using PowerShell?
- How to get the file extension using PowerShell?
Advertisements