Hello, BrianGordon84-
Yes, another idea would be to have the DiskPart commands in a file, copy the file to the target VM, and run diskpart.exe on the target VM with the "/s" parameter to use the given text file with the DiskPart commands in it.
So, it would be like:
## place on the target VM to which to copy txt file
$strDestinationTxtFilespec = "c:\temp\diskPartCmds.txt"
## copy the txt file with the DiskPart cmds from the local machine to the target VM
Copy-VMGuestFile -Source d:\importantStuff\diskPartCmds.txt -Destination $strDestinationTxtFilespec -Force -LocalToGuest -VM $myVM -GuestCredential $credPrivilegedAcct
## run diskpart.exe on the target VM, specifying the given txt file for the commands to run, and then delete the txt file
Invoke-VMScript -ScriptText "diskpart.exe /s $strDestinationTxtFilespec && del $strDestinationTxtFilespec" -VM $myVM -GuestCredential $credPrivilegedAcct -ScriptType bat -Confirm:$false
Your txt file with the DIskPart commands in it is something typical like what you had specified for the "$script" variable in your first post in this thread.
These two cmdlets depend on VMTools to be running properly in the target guest. Another nice thing about using these two cmdlets is that, since they utilize the guest's VMTools, you do not need direct network connectivity to the guest -- just vCenter access. That is, too, a possible problem: if Tools are not running/working properly, neither will the cmdlets. You could also just copy the file to the guest VM, or even generate it directly on the guest, etc.
Let me know how that does for you.