New-partition -Offset not working

Hi folks,
I have this code, it works fine if I remove the -offset

New-Partition -DiskNumber 1 -UseMaximumSize -Offset 1048576 | Format-Volume -FileSystem NTFS -NewFileSystemLabel newdrive -AllocationUnitSize 65536

I cannot get a valid Offset number to work. Its supposed to be type UInt64 - I thought that would be a factor of 64 like 64 * 1024.

Any ideas on that -Offset?

Thanks!

Do you need to set the offset?

The data type [UINT64] is just an [INT] with higher maximum … you can get it with:

[uint64]::MaxValue

BTW: if you get errors please share them completely formatted as code.

Hey Olaf,
I do need to set the offset to preferably 1MB

Thats a HUGE number:
[uint64]::MaxValue
18446744073709551615

The error:

PS C:\WINDOWS\system32> New-Partition -DiskNumber 1 -UseMaximumSize -Offset 1048576 | Format-Volume -FileSystem NTFS -NewFileSystemLabel newdrive -AllocationUnitSize 65536
New-Partition : The specified offset is not valid.
Activity ID: {f153031e-06aa-411f-9abb-d2a96da4aef2}
At line:1 char:1
+ New-Partition -DiskNumber 1 -UseMaximumSize -Offset 1048576 | Format- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (StorageWMI:ROOT/Microsoft/Windows/Storage/MSFT_Disk) [New-Partition], CimException
    + FullyQualifiedErrorId : StorageWMI 41012,New-Partition

So your disk type or partition type may not support an offset 1MB!? :man_shrugging:t4: You may try other values.

Do you already have partitions you could inspect for existing values?

I didn’t think of that, I always blame my code first.

Ill try on some other disks and see whats up.

Thanks!

If I increase the -Offset to 16777216 it works on my servers disks. That gives a ~16MB offset which is fine I think. Is there a minimum value for that? Or does it depend on other variables like disk size, partition size etc?

Great. I’m glad to hear that. :+1:t4:

I have no idea. :man_shrugging:t4:

Possible. Sounds plausible, sort of, I think. :thinking: