Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Eject CD-Drive without VM-Stop
#
# Usage:
# PowerCLI> .\eject_cd_no-msg.ps1 <VM Name>
$vm_name = $args[0]
Get-VM $vm_name | % {
$vm = $_
# Add AdvancedSetting
$vm | New-AdvancedSetting -Name cdrom.showIsoLockWarning -Value "FALSE" -Confirm:$false |
ft -AutoSize Entity,Name,Value
$vm | New-AdvancedSetting -Name msg.autoanswer -Value "TRUE" -Confirm:$false |
ft -AutoSize Entity,Name,Value
# Eject
$cd_drive = $vm | Get-CDDrive |
Set-CDDrive -NoMedia -Connected:$false -Confirm:$false
$cd_drive | Select-Object `
@{N="VM";E={$_.Parent.Name}},
@{N="StartConnected";E={$_.ConnectionState.StartConnected}},
@{N="Connected";E={$_.ConnectionState.Connected}},
IsoPath
# Remove AdvancedSetting
$vm | Get-AdvancedSetting -Name cdrom.showIsoLockWarning | Remove-AdvancedSetting -Confirm:$false
$vm | Get-AdvancedSetting -Name msg.autoanswer | Remove-AdvancedSetting -Confirm:$false
}
@gowatana

This comment has been minimized.

Copy link
Owner Author

gowatana commented Jul 15, 2018

VM停止なしで仮想CDドライブからメディアを取り出す。

参考:
https://kb.vmware.com/kb/2144053?lang=ja

@gowatana

This comment has been minimized.

Copy link
Owner Author

gowatana commented Jul 15, 2018

下記の投稿むけ。

PowerCLI で VM 停止しないように CD/DVD ドライブからメディアを取り出してみる。
https://communities.vmware.com/people/gowatana/blog/2018/07/15/powercli-cdrom-eject

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.