SOLVED

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

Copper 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 (Copper 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
1 best response

Accepted Solutions
best response confirmed by siva N (Copper 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 

View solution in original post