Created
July 15, 2018 13:35
-
-
Save gowatana/75def095ef50fa4303b43b8596672123 to your computer and use it in GitHub Desktop.
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
下記の投稿むけ。
PowerCLI で VM 停止しないように CD/DVD ドライブからメディアを取り出してみる。
https://communities.vmware.com/people/gowatana/blog/2018/07/15/powercli-cdrom-eject