Created
July 15, 2018 13:35
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
下記の投稿むけ。
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
VM停止なしで仮想CDドライブからメディアを取り出す。
参考:
https://kb.vmware.com/kb/2144053?lang=ja