I guess I'm being stupid again, but is there a way to determine on which servers VMWare Tools actually are mounted?
I executed SDRS recommendations today and noticed that one svMotion failed due to it had Tools mounted. So I figured I must be able to find all mounted tools with PowerCLI.
After a quick look around i found the command "Dismount-Tools" for dismounting and this blog post to give me a list of all VMs with tools mounted.
I also found this blog post which provided me with list of all mounted ISO's:
VM IsoPath
vm1 [Templates] ISO/en_windows_server_2...
vm2 [Templates] ISO/SW_DVD5_Windows_Svr_...
vm3 [] /usr/lib/vmware/isoimages/linux.iso
vm4 [] /usr/lib/vmware/isoimages/linux.iso
vm5 [] /usr/lib/vmware/isoimages/linux.iso
vm6 [] /vmimages/tools-isoimages/linux.iso
vm7 [] /vmimages/tools-isoimages/linux.iso
vm8 [] /usr/lib/vmware/isoimages/linux.iso
vm9 [] /vmimages/tools-isoimages/linux.iso
These two lists (mounted ISO's and mounted Tools) differed a lot. For example would vm3 not show up in the "mounted tools"-list but vm4 would show up in both. Also looking in the GUI I would have for vm4 the option to end vmware tools installation but not for vm3, there I could only see the ISO mounted. I'm not sure if these "ghost"-mounts affect vMotion/svMotion or other actions or not, but I figure I might as well unmount them too.
Is is safe to presume that all VM's with ISO Path "[]/usr/lib/vmware/isoimages/linux.iso" or "[]/vmimages/tools-isoimages/linux.iso" have tools mounted or are dismounted but that unmounting the ISO failed in some way and that "[Datastore] ..." are user/admin mounted ISO's? If so, is it preferable to use "Set-CDDrive -NoMedia" instead of "Dismount-Tools"? And what would the equivalent for Windows guests look like when looking at the ISO-path?
Secondly, any suggestions to quicken the script up (which ever alternative you suggest)?
We have 2000+ VMs and to first retrieve all VMs, then do get-view and finally filter only the wanted VMs as below one-liner executes takes quite some time:
(Get-VM | Get-View | Where {$_.Runtime.ToolsInstallerMounted}) | % {$_.Name}
Same issue really with the other one-liner, to get all VMs and then get all of their CD Drives before doing the filtering:
Get-VM | Get-CDDrive | select @{N="VM";E="Parent"},IsoPath | where {$_.IsoPath -ne $null}
Would perhaps something like below be a quicker way to determine which VMs have ISO's mounted?
Get-VM | ?{$_.CDDrives.IsoPath -ne $null}
You could try
Get-View -ViewType VirtualMachine -Property Name,"Runtime.ToolsInstallerMounted" -Filter @{"Runtime.ToolsInstallerMounted"="True"} | %{
$_.UnmountToolsInstaller()
}
That should be a bit faster.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could try
Get-View -ViewType VirtualMachine -Property Name,"Runtime.ToolsInstallerMounted" -Filter @{"Runtime.ToolsInstallerMounted"="True"} | %{
$_.UnmountToolsInstaller()
}
That should be a bit faster.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Excellent, thanks! Quick like a bunny.
Any thoughts on the "ghost"-mounts?
[] /usr/lib/vmware/isoimages/linux.iso
[] /vmimages/tools-isoimages/linux.iso
Do you only see that on VMs that have a *nix guest OS ?
Must be something that fails in the script or procedure.
Does the ISO stay mounted when the user logs off ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, it only seems to be RHEL guest.
No idea actually if it stays when user logs off, I just noticed a whole lot of mounted ISO's which seems related to Tools Upgrade when I ran "Get-VM | Get-CDDrive | select @{N="VM";E="Parent"},IsoPath | where {$_.IsoPath -ne $null}".
But I don't think it's a big deal, your other one-liner dismounts all the actually mounted Tool Upgrades which could cause a lock when performing vMotion/svMotion.