I have an issue where if the disk was not previously initialized, it will crash out when it starts the image. Looking at the deploy script, I see these lines. Would Initialize have to be before the clear-disk? When I tried that, it still does some weird things, so there must be something asynchronously happening with another script. Once it crashes out, if I reboot and run the same image, it works fine. Any help is appreciated.
Clear-Disk $hardDrive.Number -RemoveData -RemoveOEM -Confirm:$false
if($script:bootType -eq "efi")
{
Initialize-Disk $hardDrive.Number -PartitionStyle GPT
}
else
{
Initialize-Disk $hardDrive.Number -PartitionStyle MBR
}