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
########################################################################## | |
# If A CentOS Linux VM Is Returned, # | |
# Prompt For Credentials With Privileges To Eject The Media In The Guest # | |
# And Store The Credentials In The $Creds Variable # | |
# Then For Every VM Returned Eject The Media In The Guest # | |
# And Disconnect The ISO From The VM # | |
########################################################################## | |
If($CentVMs){ | |
$Creds = Get-Credential | |
Foreach ($VM in $CentVMs){ |
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
######################################################## | |
# If A Windows VM Is Returned, # | |
# For Every VM Returned Disconnect The ISO From The VM # | |
######################################################## | |
If($WinVMs){ | |
Foreach ($VM in $WinVMs){ | |
Write-Host "" | |
Write-Host "Disconnecting The ISO From "$VM.Parent.Name"" -ForegroundColor Yellow | |
Get-CDDrive -VM $VM.Parent.Name | Set-CDDrive -NoMedia -Confirm:$false > $null | |
Write-Host "" |
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
########################################### | |
# Get All CentOS Linux VMs Stored In $VMs # | |
# And Store In The Variable $CentVMs # | |
########################################### | |
$CentVMs = $VMs | Where-Object {$_.Parent.Guest.OSFullName -like "*CentOS*"} |
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
###################################### | |
# Get All Windows VMs Stored In $VMs # | |
# And Store In The Variable $WinVMs # | |
###################################### | |
$WinVMs = $VMs | Where-Object {$_.Parent.Guest.OSFullName -like "*Windows*"} |
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
########################################### | |
# Get All VMs With A Configureed ISO Path # | |
# And Store In The Variable $VMs # | |
########################################### | |
$VMs = Get-VM | Get-CDDrive | Where-Object {$_.IsoPath -ne $null} | Select-Object * |
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
########################################### | |
# Get All VMs With A Configureed ISO Path # | |
# And Store In The Variable $VMs # | |
########################################### | |
$VMs = Get-VM | Get-CDDrive | Where-Object {$_.IsoPath -ne $null} | Select-Object * | |
###################################### | |
# Get All Windows VMs Stored In $VMs # | |
# And Store In The Variable $WinVMs # | |
###################################### |
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
Write-Host "Disconnecting The ISO From "$VM.Parent.Name"" | |
Get-CDDrive -VM $VM.Parent.Name | Set-CDDrive -NoMedia -Confirm:$false > $null |
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
Write-Host "Ejecting Media In Guest For "$VM.Parent.Name"" | |
Invoke-VMScript -ScriptText "eject" -ScriptType Bash -VM $VM.Parent.Name -GuestCredential $Creds |
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
(Get-VM | Where-Object {$_.Guest.OSFullName -like "*CentOS*"} | Get-CDDrive | Where-Object {$_.IsoPath -ne $null} | Select-Object *) |
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
$Creds = Get-Credential |
NewerOlder