Quantcast
Channel: Virtual Machine Manager – General forum
Viewing all articles
Browse latest Browse all 728

Virtual Machine Manager - PowerShell Script to Delete VMs

$
0
0

Hello,

i have the following powershell script which creates muliple VMs (see below)

My questions is:

which powershell script should i write in order to delete the VMs i created.

e.g. i created 20 VMs by the script below and now i want to remove all of them.

thanks in advance.

[int]$VMcount =Read-host InputNumber of VMs


$Templatename =Read-host "Input VMTemplate Name"
$VMTemplate =Get-SCVMTemplate|where{$_.Name-eq "$Templatename"}

$VMName =Read-host InputBaseName

$Hostname =Read-host "Input Host Name"
$VMHost =Get-SCVMHost-ComputerName $Hostname

$VMPath =Read-host "Input VM Path (example: C:\Clusterstorage\Volume1)"

$Total =1While($total -le $VMCount){$NewVMName =$VMName-”+ $totalWrite-Output $virtualMachineConfigurationNew-SCVirtualMachine-Name $NewVMName -VMHost"$VMHost"-path "$VMPath"-VMTemplate"$VMTemplate"-ReturnImmediately-DelayStartSeconds0"

$Total++

}


Viewing all articles
Browse latest Browse all 728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>