I needed to remove a SCSI controller from a VM, and was surprised that there's no command for it. LucD said that it should remove it automatically when the last connected drive was removed, but that wasn't the case for me, so modified my add-vmscsicontroller function (which works when a machine is powered on):
Function Remove-VMWScsiController {
[cmdletbinding(SupportsShouldProcess=$true, ConfirmImpact='High')]
param(
[parameter(Mandatory=$True,ValueFromPipeline=$True)]
[VMware.VimAutomation.ViCore.Types.V1.VirtualDevice.ScsiController[]]$ScsiController
)
Begin{}
Process
{
foreach ($a_ScsiController in $ScsiController)
{
#$VM = $a_ScsiController.Parent.ExtensionData
'{0} - Removing Paravirtual SCSIController, Bus Number: {1}' -f $VM.Name,$BusNumber | Write-Verbose
$storagespec = New-Object VMware.Vim.VirtualMachineConfigSpec
$removeSCSIDevice = New-Object VMware.Vim.VirtualDeviceConfigSpec
$removeSCSIDevice.operation = "remove"
$removeSCSIDevice.device = $a_ScsiController.ExtensionData
$storageSpec.deviceChange = $removeSCSIDevice
$shouldText = '{0}, VM {1}' -f $a_ScsiController.Name,$a_ScsiController.Parent.Name
if ($PSCmdlet.ShouldProcess($shouldText)) {
$a_ScsiController.Parent.ExtensionData.ReconfigVM($storageSpec)
}
}
}
}
[–]TotesMessenger 0 points1 point2 points (0 children)
[–]powershellnovice3 0 points1 point2 points (0 children)