Hi Everyone,
One of the ESXi host entered into maintenance mode and it stuck at 19% but check the VM's edit setting be uase the Tasks is running. Can we see or check from Power Cli if any CD rom mounted or the VM's in local storage? If yes, can we umount the CD rom from power Cli ?
thanks in advance.
regards,
vmk
Yes, you can do
Get-VM | Get-CDDrive | where{$_.IsoPath} |
Set-CDDrive -NoMedia -Confirm:$False
To find the VMs that are on local storage, you could do
Get-VM | where{Get-Datastore -RelatedObject $_ | where {$_.ExtensionData.Info.Vmfs.IsLocal}} |
Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, the CD can be unmounted.
Try like this
Get-VM | Get-CDDrive |
Set-CDDrive -NoMedia -Confirm:$False
Not sure what you mean with the 'local storage' remark.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Can we check first if the CD rom really mounted ? local storage i mean that if the VM is in local storage then it might fail.
PS C:\temp>
PS C:\temp> Get-VM cbv | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$False
Set-CDDrive : 12/31/2018 5:14:05 AM Set-CDDrive Server task failed: The operation is not allowed in the
current state
of the host.
At line:1 char:40
+ ... cbv-cscddsview1 | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$False
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-CDDrive], VimException
+ FullyQualifiedErrorId : Security_Impl_TaskResultConverter_TaskNotSucceeded,VMware.VimAutomation.ViCore.Cmdlets.C
ommands.VirtualDevice.SetCDDrive
Yes, you can do
Get-VM | Get-CDDrive | where{$_.IsoPath} |
Set-CDDrive -NoMedia -Confirm:$False
To find the VMs that are on local storage, you could do
Get-VM | where{Get-Datastore -RelatedObject $_ | where {$_.ExtensionData.Info.Vmfs.IsLocal}} |
Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Luckily, i got downtime for the VM's because of Dev & Test and shut down the VM's, hence finally host went to Maintenance mode.
Thanks
vmk
LucD,
Can we get the lists of VM's having CD ROM mounted and ISO image and then based on out we will unmount it ?
You can do something like this
Get-VM | where {Get-CDDrive -VM $_ | where {$_.IsoPath}} | Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Can we also pull VM name with ESXi host also, so that before putting the host into maintenance mode we can unmount the CDrom and iso ?
Also, once we identify the VM's names, can we unmount from the lists of VM's ? C:\vmliste.txt
This will add the VMHost into the report.
Select Name, @{N = 'VMHost'; E = {$_.VMHost.Name}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
And this will use the report, to unmount the ISOs
ForEach-Object -Process {
Get-VM -Name $_.Name | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LuCD. Before unmounting it, can we determine if the mount is for VMware tools or Windows Installations?
You can check the value in IsoPath.
When the VMware Tools ISO is mounted, you should see the VM with this
where { Get-CDDrive -VM $_ | where {$_.IsoPath -match '/usr/lib/vmware/isoimages'}} |
select Name
For Windows ISOs it is similar, but you will have to find the name of the ISO.
That depends on which version and how those ISOs are distributed in your environment.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference