I used the following PowerShell script, try it:
# Prompt for credentials
$vcServer = "vcenter.yourdomain.local"
$vcUser = "username"
$vcPass = Read-Host -Prompt "Enter password for $vcUser" -AsSecureString
# Connect to vCenter
Connect-VIServer -Server $vcServer -User $vcUser -Password $vcPass
# Path to VM list text file (one VM name per line)
$vmListPath = "C:\Path\To\VMlist.txt"
# Remove CD/Drive1 from each VM in the list
Get-Content $vmListPath | ForEach-Object {
$vmName = $_.Trim()
if ($vmName) {
$cdDrive = Get-VM -Name $vmName | Get-CDDrive
if ($cdDrive) {
Remove-CDDrive -CDDrive $cdDrive -Confirm:$false
Write-Host "Removed CD/Drive from VM: $vmName"
} else {
Write-Host "No CD drive found for VM: $vmName" -ForegroundColor Yellow
}
}
}
# Disconnect from vCenter
Disconnect-VIServer -Server $vcServer -Confirm:$false
-------------------------------------------