Windows Server: Increase User Profile Disk Size


If you have enabled user profile disks on your RDS farm and need to increase the size of a disk, you must go through a machine with the Hyper-V role installed to have the virtual disk management tools.

Step 1: Install the hyper-v role on a virtual machine (optional)
We will start by installing the Hyper-V role on a virtual machine. It must be under Windows Server 2012R2 at least.

If you go through server manager, Windows won't want to install the role on a virtual machine. You have to do it with PowerShell.
Enter the following command to install the Hyper-V role:
Enable-WindowsOptionalFeature –Online -FeatureName Microsoft-Hyper-V –All -NoRestart
Enter the following command to install the Hyper-V management tools
Install-WindowsFeature RSAT-Hyper-V-Tools -IncludeAllSubFeature
Reboot the virtual machine to complete the installation.
Restart-Computer

Step 2: Increase the size of the user profile disk
You can do this in two ways, either from the command line with PowerShell or by using the Hyper-V graphical tools.
Copy the profile disk (UPD) to be resized to the computer where Hyper-V is installed.
With PowerShell
Load the Hyper-V PowerShell module:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell

Resize VHD profile disk:
Resize-VHD "C:\upd\NomDuFichier.vhdx" –size XXGB
Go to step 3: extend the partition
Now you need to extend the volume from the Disk Management Console GUI (Action -> Attach VHD -> Extend Volume).

Or use the following PowerShell script to automatically extend the vhdx file to the maximum size available:

<#
.Synopsis
This script extend size of VHDX file and resize the disk partition to Max

#>
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[alias("Path")]
[string]$vhdxFile,
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[alias("Size")]
[int64]$vhdxNewSize
)
begin{
try {
Mount-VHD -Path $vhdxFile -ErrorAction Stop
}
catch {
Write-Error "File $vhdxFile is busy"
Break
}
$vhdx = Get-VHD -Path $vhdxFile
if ($vhdx.Size -ge $vhdxNewSize){
Write-Warning "File $vhdxFile already have this size!"
$vhdx | Dismount-VHD
Break
}
}
process{
Dismount-VHD -Path $vhdxFile
Resize-VHD -Path $vhdxFile -SizeBytes $vhdxNewSize
$vhdxxpart = Mount-VHD -Path $vhdxFile -NoDriveLetter -Passthru | Get-Disk | Get-Partition
$partsize = $vhdxxpart | Get-PartitionSupportedSize
$vhdxxpart | Resize-Partition -Size $partsize.SizeMax
}
end{
Dismount-VHD -Path $vhdxFile
}
Note that you cannot expand the user's UPD disk with an active RDS session.

No comments

Powered by Blogger.