It's a delta disk from a snapshot. In the original VM, this is what Get-Harddisk returns where there is currently only one snapshot:
StorageFormat : Thin
Persistence : Persistent
DiskType : Flat
Filename : [BOOT] Server 2016 Sysprepd/Server 2016 Sysprepd-000001.vmdk
CapacityKB : 41943040
CapacityGB : 40
ParentId : VirtualMachine-64
Parent : Server 2016 Sysprepd
Uid : /VIServer=root@192.168.xx.xx:443/VirtualMachine=VirtualMachine-64/HardDisk=2000/
ConnectionState :
ExtensionData : VMware.Vim.VirtualDisk
Id : VirtualMachine-64/2000
Name : Hard disk 1
It's thin provisioned. So I copied this vmdk, and the associated sesparse.vmdk binary file, to the folder for the new VM my script has created, renamed the files and then changed the parentFileNameHint line to point back to the base disk for this delta disk and changed the extents to the renamed file as per my earlier post.
It's at that point when I call New-HardDisk on my copied, renamed and edited vmdk file that I get the error but if I add the same disk to the same VM via the web console then it works fine.
I've looked at the hostd.log file trying to spot the difference from when it works via the web console to when it fails via PowerCLI but I can't see anything obvious.
Thanks for your continued help on this.