Hello, jrich523-
Hm, I was not able to reproduce the "crashes" that you talk about. I wonder, what version of PowerCLI are you using? You can get that info by running:
PS C:\> Get-PowerCLIVersion
How does the Remove-Datastore do if you pass the array of datastores ("$datastores") directly to it, instead of one datastore at a time in a Foreach-Object loop? So, the last line would be like (with the confirmation suppression added):
Remove-Datastore -Datastore $datastores -VMHost $vmhost -Confirm:$false
(since, per the docs, the cmdlet accepts an array of datastore objects -- you do not have to pass them in one at a time)
And, I assume that the ">" in the first line is just a type, and that it is really a "%" in your code -- is that true?