Application virtualization, IoT and Cloud Computing, Blog of Sacha Thomet

Monitor you Profile directories

Since I had worked as a Citrix administrator the size of the profile directories was always a contemporary issue. It’s a fact that with new technologies like Citrix User Profile Manager the possibilities are grown and the life is easier with exclusion lists and profile streaming features. But it’s still a topic to consider if you are a Citrix admin or system engineer. I worked in former company with tools like TreeSize ( or WinDir Stat ( But in some company they wont to spend money for tools which is only usable for one administrator or they don’t trust to OpenSource software (TreeSize).

I have the approach to solve every possible problem with on-board tools. So I created now a small script what give me the possibility to check my Profile directory with one recursive level so that I get each Size of a Profile within his subdirectories.:

# Created on: 10.2015 Version: 0.3
# Created by: Sacha Thomet
# Filename: GetSubdirSizes.ps1
# Description: This script checks some Citrix Provisioning Server, Farm, vDisk & Target device parameters.
# Prerequisite: None
# Call by : Manual
# Change Log:
# V0.1 first version
# V0.2 only 1 recursive subfolder
# V0.3 corrections of calculation

$path = "\\localhost\C$\temp\profiles\"
$top = "4000"
$outputpath = "C:\temp\SubdirSize-Report.txt"

Function Get-FolderSize
 $Sizes = 0
 ForEach ($Item in (Get-ChildItem $Path))
 If ($Item.PSIsContainer) {$Sizes = (Get-ChildItem $path"$Item" -recurse | Measure-Object -property length -sum).sum}
 Else {Write-Host "No Subfolder"}

 $SizeFormated = "{0:N2}" -f ($Sizes/1MB)
 New-Object PSObject -Property @{'Folder'=$Item;'Size'=$SizeFormated }
$outfile = Get-FolderSize $path | sort -property Size –Descending |select -first $top
$outfile | out-file $outputpath
echo $outfile

5 Responses to Monitor you Profile directories

  • Love it. I had to do the same thing in one of my environments I monitored. I also have a script somewhere that will delete the profile if the users profile wasn’t updated in a year. With this delete process it would also generate a log of the profiles that were deleted which was nice for reporting.

    You only have to create a delete script if you don’t have a good user retention/deletion process 🙁

    • Can you share the delete script as well? I work for one of those “don’t have a good user retention / deletion process” companies. 😉

      Thanks for this awesome script also! One thing I noticed is that when copy / pasting as a .ps1 file, I got an error on line 37 before the -Descending .. had to backspace and re-enter.. think there’s some ascii issue with the copy / paste.

      • Brad, to be honest I do this manually because we have not so many profiles grow to much. But what I can provide you is a Script which moves a list of directories fro a file (userdirtoremove.txt) in an other folder.
        You can delete them a week later …

        Just use Excel to find your Top10 or Top100 Profiles you like to remove.

        I have also a script which compare the directories and Activedirectory to find orfan profiles … Maybe I’ll share that soon in a new blog article.

        This is the script to move directories from a list in a file:

        # define paths and usernamesuffix
        $sourcepath = “\servershare$ts8k” #Source
        $destpath = “\servershare$ts8kto_delete” #Destination
        $inputfile = “C:Scriptsuserdirtoremove.txt”

        $subdirsuffix = “.w2k8” #optional if you have a suffix after to profile e.g. username is U123456 and profile-dir is U123456.w2k8

        # — don’t change below

        #Get the Subdir names into array $subdirname

        $FileContent = Get-Content $inputfile

        foreach($content in $FileContent)


        Write-Host “Moving Direcotry $content$subdirsuffix from $sourcepath to $destpath”
        Move-Item $sourcepath$content$subdirsuffix $destpath


  • Thanks for this – it really helps me, although I get an error if a subdirectory is empty – which most of our profiles are. Can someone adjust the script to cater for this?

Leave a Reply

Your email address will not be published. Required fields are marked *