PowerShell script for checking profile size of a user

Powershell:

 

#—- parameters

#the folder with all the home drives for the different users
$homefolderrootpath = “\\exampledomain.local\users\Home”
#Folderpath after username \\exampledomain.local\users\harry\<foldersname>
$PathAfterUsername = “pwrmenu”
#txt save location and file
$txtsavepath = “C:\temp\userpwrmenusize.txt”

#—- Script
Del $txtsavepath
# get homefolder names
$maps = Get-ChildItem $homefolderrootpath -name

Foreach ($map in $maps) {
#Set path that contains profile
$pathuserProfile = $homefolderrootpath+ “\” + $map + “\” + $PathAfterUsername
#Get size of folder incl subfolders
$colItems = (Get-ChildItem $pathuserProfile -recurse| Measure-Object -property length -sum)
#convertt to MB
$sizeplusname = “{0:N2}” -f ($colItems.sum / 1MB) + “,MB,” + $map
# Write to file
$sizeplusname | Out-File $txtsavepath -Append

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s