In your vSphere environment that is managed by a single vCenter Server, you have determined that no VM needs to currently utilize a virtual CD drive. You notice that the vSphere client provides no direct means to easily disconnect the CD drive for a set of VMs. You obtained the following PowerCLI script from a colleague that may correct the problem:
Connect-VIServer vcenter01
Get-VM | Where-Object {$_.PowerState –eq “Powered On”} | Get-CDDrive | Set-CDDrive –NoMedia -Confirm:$False
The script appears to have syntax and potentially other issues.
VDCA510 Objective: 8.1 Execute VMware Cmdlets and Customize Scripts Using PowerCLI
VDCA550 Objective: 7.1 Execute VMware Cmdlets and Customize Scripts Using PowerCLI
Connect-VIServer vcenter-01
Get-VM | Where-Object {$_.PowerState –eq “PoweredOn”} | Get-CDDrive | Set-CDDrive –NoMedia -Confirm:$False