jduran04
asked on
Powershell Script for Directory Size
I am looking for a script to list the size of all home directories. Does anyone have a PowerShell Script for this? Or can they guide me in the right direction. Thanks.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Here is my batch file version.
Cheers,
Rene
Cheers,
Rene
@ECHO OFF
SETLOCAL enabledelayedexpansion
IF EXIST %~n0.txt DEL %~n0.txt
FOR /F "delims=" %%A IN ('DIR /b /a:d') DO (
FOR /F "tokens=1-4 delims= " %%B IN ('DIR /S "%%A"') DO (
ECHO %%C | FINDSTR -i "File(s)" >NUL && SET FolderSize=%%D %%E
)
ECHO [%%A] [!FolderSize!]
)
ECHO.
PAUSE
EXIT
Disregard line 5
With defining the home folder
@ECHO OFF
SETLOCAL enabledelayedexpansion
SET HomeFolder=C:\BatchFiles
PUSHD "%HomeFolder%"
FOR /F "delims=" %%A IN ('DIR /b /a:d') DO (
FOR /F "tokens=1-4 delims= " %%B IN ('DIR /S "%%A"') DO (
ECHO %%C | FINDSTR -i "File(s)" >NUL && SET FolderSize=%%D %%E
)
ECHO [%%A] [!FolderSize!]
)
POPD
ECHO.
PAUSE
EXIT
ASKER
Thanks.
http://technet.microsoft.com/en-us/library/ff730945.aspx
http://iformattable.blogspot.com/2007/07/powershell-script-to-determine.html