Automation

 View Only
  • 1.  delete vm script

    Posted Apr 19, 2023 03:08 PM

    I am deleting VM from this command

     

    import-csv -path csvfile | select-Expandproperty VM | % { remove-vm -VM $_ -DeletePermanately -confirm:$false }

     

    This is taking a long time. one by one. Is there way to speed this up and get verbose loggging and log to file?



  • 2.  RE: delete vm script

    Posted Apr 19, 2023 04:42 PM

    What is the column name in the VM that holds the name of the VM?
    Remove-VM accepts an array so you could pass all VMs in 1 call.
    The bottleneck would then be your vSphere environment.

    Try like this

    $vms = Import-Csv -Path csvfile -UseCulture 
    Remove-VM -VM $vms.VM -DeletePermanately -Confirm:$false