Simple way to create quota reports with powershell


A week after we began to charge departments for large quotas the IT coordinator requested a report of all their users quotas.
In this case i chose to use an CSV-file so i easy can feed the CSV with other users if a get further requests in the future.
The CSV looks like this:

The New-FsrmScheduledTask schedules a task 15:00 the fourteenth every month.

#NAME: qouta_report.ps1
#AUTHOR: Viktor Lindström
#COMMENTS: Send an email with quota report.

$förvaltning = $import.förvaltning
$mapp = $import.mapp
$mail = $import.mail
$task = New-FsrmScheduledTask -Time "15:00" -Monthly 14

foreach ($item in $import)
    New-FsrmStorageReport  -Name $item.förvaltning -Namespace @($item.mapp) -ReportType @("QuotaUsage") -MailTo $item.mail -ReportFormat @("CSV","DHTML") -schedule $task

Migrate quota to new disk

In our project to migrate all our servers from our old SAN and VMware environment to our brand new top of the line EMC VNX VPlex SAN and new Dell VMware-hosts, we only have one server left, the server that hosts the home directories for all our users(except students). In our old environment we have an 12 terabyte raw device mapping, so the only way to migrate it with VMware is by cold migration and approximately 48 hours of down time. we also wanted to shrink it and convert it to a vmdk instead of an rdm. We decided to create a new vmdk-disk and use robocopy to copy all the files, doing so we reduce downtime for our users and gets a new smaller disk. Robocopy don´t copy folder quotas and we have pretty complex quota structure with individual quotas  on each users(about 8000) home directory, therefor me and my college Stefan Lozancic created a script to that migrates all quotas to the new disk.

#NAME: Migratequota.ps1
#AUTHOR: Viktor Lindström and Stefan Lozancic
#COMMENTS: Migrate File Quotas to new disk

Get-FsrmQuota | select path, template | foreach 
$_.path = $_.path.replace("D:","F:")
New-FsrmQuota -Path $_.path –Template $_.template

Create quota templates

Last year I was involved in a project where the goal was to migrate the users home directories from an old Windows 2003 server to a new Windows 2012 and going from no quotas to 30 different quotas. In the POC I created this script to setup the quota templates with warning messages and thresholds, and I am glad i did since the project changed the template size and the body in the email a couple of times.

#NAME: CreateQuotaTemplate.ps1 
#AUTHOR: Viktor Lindström
#COMMENTS: Write the quotas that are to be created in the $G 
#variable, for exaple if you write 1,2,3 it creates templates
#with 1GB, 2GB and 3GB, if you write 1..24 it will create 24 
#templates etc etc... It also creates two thresholds with
#mail action to the user. 
$GB = 1..24

foreach ($a in $gb) 
#Create action
    $Action= New-FsrmAction Email -mailto "[Source File Owner Email]" -Subject "[Quota Threshold]% av kvotan i din hemkatalog är uppnådd." -Body "Hej Du har överskridit [Quota Threshold]% av kvotabegränsningen i din hemkatalog. Tilldelad kvot är [Quota Limit MB] MB, och för tillfället används [Quota Used MB] MB ([Quota Used Percent]% över gränsen)."
#Create thresholds
        $Threshold = New-FsrmQuotaThreshold -Percentage 80 -action $Action
        $Threshold2 = New-FsrmQuotaThreshold -Percentage 95 -action $Action
#Create quota, shage the two GB to MB if you what megabytes instead of gigabytes    
        $Namn = ("$a" + "GB")
            New-FsrmQuotaTemplate -name $Namn -size ([int64]($a) * [int64]1GB) -Threshold $Threshold,$Threshold2