Closed indyK1ng closed 6 years ago
I assume that you don't want to specify the Size
property, but want the Size
to be "current size of entire disk" (not sure that equals to "remaining free space" above), and together with AllowDestructive
should resize the partition?
Feels that the scenario you looking for is not tested among those "AllowDestructive" tests. Closest is this one; https://github.com/PowerShell/StorageDsc/blob/b31dbc236c6c7542f344a3eee5b8aa6b6055d0f4/Tests/Unit/MSFT_Disk.Tests.ps1#L1663-L1722
I think we should add a test for that scenario.
Hoping someone in the community can answer this better.
/cc @PlagueHO
Not the entire disk - if there's another partition on the disk we don't want to delete it. That's what I mean by "remaining free space", the unpartitioned space remaining on the disk. Other than that, yes I want it to resize the partition with AllowDestructive
when no Size
is specified to use up any space not in a partition.
I also didn't see any tests that cover this case and, like I said, I'm pretty sure the behavior is at the whim of how Resize-Partition handles Size being $null
. I tested it this morning and got an error.
This sounds like a bug, labeling it as such, and help wanted so that anyone in the community can run with this.
It does indeed look like this is a bug and should be able to be fixed fairly easily by setting $Size
to $supportedSize
if Size
is not set in the resource just before this line (https://github.com/PowerShell/StorageDsc/blob/2f8d3200aa799ea34ebae4c20707aefc27f6225b/Modules/StorageDsc/DSCResources/MSFT_Disk/MSFT_Disk.psm1#L499). I'll try and get a fix through for this tomorrow or the weekend.
This has required a bit more to it than what I first thought. Hopefully won't be much longer. Needed a lot more new tests to really validate that this isn't going to break anything.
This is a question about the existing functionality.
Can we use this to resize a volume to use the remaining free space of a drive in addition to its existing space?
We would like to use this to resize partitions on VMs if the virtual disk has been resized. The wiki documentation says regarding Size: "Specifies the size of new volume. Leave empty to use the remaining free space."
However, reading the code for MSFT_Disk's handling of existing partitions, it looks like if size is not specified it might try to resize the partition to $null because $Size hasn't been set and $null is not equal to $assignedPartition.Size. At this point, behavior is up to if Resize-Partition errors when the -Size parameter is $null.