Valrok
Valrok

Reputation: 1584

Get ISO's mounted and change device type to client

I'm trying to find a way with PowerCLI to get a list of ISO's that are mounted in VM's and change the device type to "client device." Originally I thought that using the get-datastore would work to find the ISO's, however I was struggling to find ISO's, and ran into this line of code while doing some searching:

(Get-VM | Get-View | Where {$_.Runtime.ToolsInstallerMounted}) | % {$_.Name}

I tried this, however I didn't get a list of ISO's mounted. Was wondering if anyone here might know how to get a list of ISO's mounted on VM's and change the device type to client through scripting.

Upvotes: 3

Views: 5919

Answers (1)

Shay Levy
Shay Levy

Reputation: 126912

Try this, remove WhatIf to remove the ISO:

Get-VM | 
Get-CDDRive | 
Where-Object {$_.IsoPath} | 
Set-CDDrive -NoMedia -Confirm:$false -WhatIf

Upvotes: 5

Related Questions