Anwendungsvirtualisierung, Internet der Dinge und Cloud Computing, Blog von Sacha Thomet

Überwache die Profile Verzeichnisse

Bereits vor Jahren als ich als Citrix Admin gearbeitet habe waren die anwachsenden Benutzerprofileverzeichnisse immer wieder ein Thema. Klar ist das Administratorenleben nun mit neueren Technologien wie dem Citrix User Profile Manager oder anderen 3rd Party Lösungen einfacher geworden, Profile Streaming und Exclusions können viel wert sein.

Trotzdem ist es immer noch ein Thema das als Citrix Admin oder Engineer berücksichtigt werden muss. In einer früheren Firma habe ich  Tool’s wie Treesize  ( oder WinDirStat( gearbeitet. Aber es gibt halt firmen die kein Geld für solche Tools ausgeben wollen oder auch OpenSource nicht trauen, bzw. der Softwareintegrationsprozess kompliziert und langwierig ist.

So hatte ich den Ansatz dieses Profilgrössenproblem mit Bordmitteln zu lösen. Ich habe nun ein kleines PoSh-Script erstellt welches mir rekursiv durch meine Profilordner läuft und die Grössen ausgibt.

# 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 Antworten auf Überwache die Profile Verzeichnisse

  • 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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow me on Twitter