SOLVED

Need to export the multiple child folders size from NAS storage via powershell from my computer

%3CLINGO-SUB%20id%3D%22lingo-sub-94764%22%20slang%3D%22en-US%22%3ENeed%20to%20export%20the%20multiple%20child%20folders%20size%20from%20NAS%20storage%20via%20powershell%20from%20my%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-94764%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20have%20the%20NAS%20storage%20and%20we%20are%20all%20accessing%20our%20users%20profiles%20and%20share%20profiles%20from%20the%20NAS%20storage.%3CBR%20%2F%3EWe%20need%20to%20restrict%20the%20users%20profiles%20size%20below%20500%20MB%20thershold%2C%20So%20is%20it%20possible%20to%20generate%20the%20users%20profile%20size%20automated%20report%20to%20each%20user%20using%20powershell.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-94764%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ENeed%20to%20export%20the%20multiple%20child%20folders%20size%20from%20NAS%20storage%20via%20powershell%20from%20my%20computer%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-106600%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20to%20export%20the%20multiple%20child%20folders%20size%20from%20NAS%20storage%20via%20powershell%20from%20my%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-106600%22%20slang%3D%22en-US%22%3Eerror%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-97464%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20to%20export%20the%20multiple%20child%20folders%20size%20from%20NAS%20storage%20via%20powershell%20from%20my%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-97464%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3Etry%20this%20script%20for%20get%20folder%20size%20from%20ad%20user%20profile%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EImport-module%20ActiveDirectory%0A%24FolderList%20%3D%40()%0A%24adusers%3DGet-ADUser%20-Filter%20*%20-Properties%20Profilepath%20%20%7Cselect%20Name%2CProfilePath%20%0A%0AForeach%20(%20%24aduser%20in%20%24adusers)%0A%7B%0AIf(%24aduser.ProfilePath%20-ne%20%24null)%0A%7B%0A%24colItems%20%3D%20(Get-ChildItem%20%24aduser.ProfilePath%20-recurse%20%7C%20Measure-Object%20-property%20length%20-sum)%0A%22%24startFolder%20--%20%22%20%2B%20%22%7B0%3AN2%7D%22%20-f%20(%24colItems.sum%20%2F%201MB)%20%2B%20%22%20MB%22%0A%20%24Folders%20%3D%20%22%22%20%7C%20Select%20%22Username%22%2C%22Folderpath%22%2C%22SizeinMB%22%0A%20%24folders.Username%20%3D%20%24aduser.name%0A%20%24Folders.Folderpath%20%3D%20%24aduser.ProfilePath%0A%20%24Folders.SizeinMB%20%3D%20%24colItems.sum%20%2F%201MB%0A%20%24FolderList%20%2B%3D%20%24Folders%0A%20%24Folders%20%3D%20%24null%0A%7D%0A%0A%7D%0A%0A%24FolderList%20%7C%20Export-csv%20c%3A%5CUsers%5Cadministrator%5CDesktop%5Cfoldersize.csv%20-NoTypeInformation%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95534%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20to%20export%20the%20multiple%20child%20folders%20size%20from%20NAS%20storage%20via%20powershell%20from%20my%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95534%22%20slang%3D%22en-US%22%3EAnd%20one%20more%20information%20--%20The%20profiles%20are%20configured%20in%20AD%2C%20Can%20we%20write%20the%20script%20to%20connect%20AD%20profile%20tab%20and%20get%20the%20profile%20path%20folder%20sizes%20for%20all%20users%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95533%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20to%20export%20the%20multiple%20child%20folders%20size%20from%20NAS%20storage%20via%20powershell%20from%20my%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95533%22%20slang%3D%22en-US%22%3EThank%20You%20..%20It's%20work%20.%20Is%20it%20possible%20to%20get%20folder%20size%20details%20for%20specific%20folder%20name%3F%20Because%20the%20users%20profiles%20folders%20are%20defined%20in%20same%20folder%20name%20EX%3A%20profile1%2C2%2C3..%20..%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-94857%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20to%20export%20the%20multiple%20child%20folders%20size%20from%20NAS%20storage%20via%20powershell%20from%20my%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-94857%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EYou%20can%20try%20this%20script%20.%3C%2FP%3E%3CPRE%3E%24RootFolder%20%3D%20%22E%3A%5CProfiles%22%0A%24paths%20%3D%20Get-ChildItem%20%24RootFolder%20%20%20%0A%24FolderList%20%3D%40()%0AForeach%20(%20%24path%20in%20%24paths)%0A%7B%0A%0A%0A%24colItems%20%3D%20(Get-ChildItem%20%24path.Fullname%20-Recurse%20%7C%20Measure-Object%20-property%20length%20-sum)%0A%20%24Folders%20%3D%20%22%22%20%7C%20Select%20%22Folderpath%22%2C%22SizeinMB%22%0A%20%24Folders.Folderpath%20%3D%20%24path.Fullname%0A%20%24Folders.SizeinMB%20%3D%20%24colItems.sum%20%2F%201MB%0A%20%24FolderList%2B%3D%20%24Folders%0A%20%24Folders%20%3D%20%24null%0A%0A%7D%0A%0A%24FolderList%20%7C%20Export-csv%20c%3A%5Cfoldersize.csv%20-NoTypeInformation%20%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

We have the NAS storage and we are all accessing our users profiles and share profiles from the NAS storage.
We need to restrict the users profiles size below 500 MB thershold, So is it possible to generate the users profile size automated report to each user using powershell.

5 Replies
Best Response confirmed by siva N (Occasional Contributor)
Solution

Hi,

You can try this script .

$RootFolder = "E:\Profiles"
$paths = Get-ChildItem $RootFolder   
$FolderList =@()
Foreach ( $path in $paths)
{


$colItems = (Get-ChildItem $path.Fullname -Recurse | Measure-Object -property length -sum)
 $Folders = "" | Select "Folderpath","SizeinMB"
 $Folders.Folderpath = $path.Fullname
 $Folders.SizeinMB = $colItems.sum / 1MB
 $FolderList+= $Folders
 $Folders = $null

}

$FolderList | Export-csv c:\foldersize.csv -NoTypeInformation 
Thank You .. It's work . Is it possible to get folder size details for specific folder name? Because the users profiles folders are defined in same folder name EX: profile1,2,3.. ..

And one more information -- The profiles are configured in AD, Can we write the script to connect AD profile tab and get the profile path folder sizes for all users?

Hi,

try this script for get folder size from ad user profile 

 

Import-module ActiveDirectory
$FolderList =@()
$adusers=Get-ADUser -Filter * -Properties Profilepath  |select Name,ProfilePath 

Foreach ( $aduser in $adusers)
{
If($aduser.ProfilePath -ne $null)
{
$colItems = (Get-ChildItem $aduser.ProfilePath -recurse | Measure-Object -property length -sum)
"$startFolder -- " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB"
 $Folders = "" | Select "Username","Folderpath","SizeinMB"
 $folders.Username = $aduser.name
 $Folders.Folderpath = $aduser.ProfilePath
 $Folders.SizeinMB = $colItems.sum / 1MB
 $FolderList += $Folders
 $Folders = $null
}

}

$FolderList | Export-csv c:\Users\administrator\Desktop\foldersize.csv -NoTypeInformation