Hello,
Did you try that :
# Variable specifying the drive you want to extend
$drive_letter = "C"
# Script to get the partition sizes and then resize the volume
$size = (Get-PartitionSupportedSize -DriveLetter $drive_letter)
Resize-Partition -DriveLetter $drive_letter -Size $size.SizeMax
You can find more information in this article :
https://learn.microsoft.com/en-us/windows-server/storage/disk-management/extend-a-basic-volume
Regards,