Hectic day ahead after reading a list of VMware KB articles on how to improve the virtual machine performance. I am surprise that there are some little tweak here and there to improve a virtual environment and half the time Administrator took the virtual environment for granted. Everything is virtual in the cloud and expect the cloud to remain as just a pure white cloud expecting environment maintenance negligence will never lead to a stormy day.
Reading on these VMware KB articles, I found consistent emphasize on removing unused removable devices or configuration that will cause a bit of poor generic performance of an individual virtual machine which in theory it should fine if only when your cloud environment is relatively small. But the logic of having a cloud environment is to have more virtual machine running in a shared resource to maximise the output with minimum cost overhead on hardware. Hmmmm…
Eventually, an audit to find out all the VMware CD Drive attached to those virtual machines are configured according to Best Practises is required which lead to developing this Get-VMWareCDDrive script that I am happy to share. I have also included the VMware KB Article links in the PowerShell Comment Code section as a reference guide.
Hope all the cloud administrators out there will like this. Goodnight to all those hardworking midnight coders. I might post another script to get virtual Floppy Drive configuration information tomorrow if I’m not too tired.
Download Link – http://gallery.technet.microsoft.com/Get-VMWareCDDrive-b506e100
function Get-VMwareCDDrive { <# .SYNOPSIS Get the VMWare Virtual Machine virtual CD Drive configuration information. .DESCRIPTION Allows the administrator to get the virtual CD Drive configuration information on the virtual machine from VMWare vCenter. .PARAMETER ComputerName ALIAS -VI This parameter specify host connection to the VMWare vCenter .PARAMETER GuestName ALIAS -Guest This parameter allows administrator to specify the VM Guest name .PARAMETER Username ALIAS -U This parameter allows administrator to specify username to authenticate with the server. .PARAMETER Password ALIAS -P This paramter allows administrator to specify the password to authenticate with the server. .EXAMPLE This example demostrate how to import the Get-VMWareCDDrive.psm1 module and use the command to query the VMWare vCenter for VMWare virtual CD Drive information on guest virtual machine name VM1 that has 2 virtual CD Drives. Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Get-VMWareCDDrive.psm1 Get-VMWareCDDrive -VI VMWarevCenter -U Redmond\VirtualCenterAdministrator -P C0nt0s0 -Guest VM1 GuestName : VM1 VMHost : esx11.redmond.com UUID : 5070f400-8066-f583-5364-785c6fc346fd OperatingSystem : Microsoft Windows 8 (64-bit) PowerState : PoweredOff NumberOfCDDrives : 2 ChangeVersion : 2013-10-14T22:02:46.292876Z DeviceName : CD/DVD drive 2 IsoPath : [MSFT_PROD_VMFS_T1_3PAR_11] MS ISO/Windows 8.1/en_windows_8_1_enterprise_x64_dvd_2791088.iso HostDevice : RemoteDevice : Connected : False StartConnected : True AllowGuestControl : True Status : untried GuestName : VM1 VMHost : esx11.redmond.com UUID : 5070f400-8066-f583-5364-785c6fc346fd OperatingSystem : Microsoft Windows 8 (64-bit) PowerState : PoweredOff NumberOfCDDrives : 2 ChangeVersion : 2013-10-14T22:02:46.292876Z DeviceName : CD/DVD drive 1 IsoPath : HostDevice : No Devices available RemoteDevice : Connected : False StartConnected : False AllowGuestControl : True Status : untried .EXAMPLE This example demostrate how to generate a report of all the VMWare virtual CD Drive information for each virtual machine in VMWare vCenter and export to a CSV file. Get-VMWareCDDrive -ComputerName VMWarevCenter | Export-Csv C:\Temp\Get-VMWareCDDrive.csv -NoTypeInformation .NOTES Title : PowerShell Get VMWare virtual CD Drive FileName: Get-VMWareCDDrive.psm1 Author : Ryen Kia Zhi Tang Date : 15/10/2013 Blog : ryentang.blogspot.com Version : 1.0 Change Log 16/10/2013 - Added Disconnect-VIServer to disconnect from vCenter cleanly. Added Remove-PSSnapin to remove VMWare PowerShell CLI cleanly. #> param( [Parameter( Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] [Alias('VI')] [String] $ComputerName = $env:COMPUTERNAME, [Parameter( Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] [Alias('U')] [String] $Username, [Parameter( Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] [Alias('P')] [String] $Password, [Parameter( Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] [Alias('Guest')] [String] $GuestName ) BEGIN {} PROCESS { # Add VMWare PowerCLI PSSnapin Add-PSSnapin VMware.VimAutomation.Core # Verify Username and Password parameter is not null and construct PSCredential object for authentication if(($Username -ne "") -and ($Password -ne "")){ # Construct Credential $PWD = convertto-securestring $Password -asplaintext -force $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$PWD # Establish connection using Credential Object $Connection = Connect-VIServer -Server $ComputerName -Credential $Credential -Force -Verbose # Verify Username and Password parameter is null and use Windows Integrated Authentication }else{ # Establish connection using Windows Integrated Authentication $Connection = Connect-VIServer -Server $ComputerName -Force -Verbose } # Verify GuestName parameter is not null if($GuestName -ne "") { # Get specific VM Guest $VMs = Get-VM -Name $GuestName }else{ # Get all VM Guests $VMs = Get-VM } # Construct Result foreach($VM in $VMs) { foreach($vCDDrive in $(Get-CDDrive -VM $VM.Name)) { $VM | Select @{L='GuestName';E={($_.Name)}}, @{L='VMHost';E={($VM.VMHost)}}, @{L='UUID';E={(((($VM).ExtensionData).Config).Uuid)}}, @{L='OperatingSystem';E={((($VM).Guest).OSFullName)}}, @{L='PowerState';E={($VM.PowerState)}}, @{L='NumberOfCDDrives';E={((Get-CDDrive -VM $VM.Name | Measure-Object).Count)}}, @{L='ChangeVersion';E={(((($VM).ExtensionData).Config).ChangeVersion)}}, @{L='DeviceID';E={($vCDDrive.ID)}}, @{L='DeviceName';E={($vCDDrive.Name)}}, @{L='IsoPath';E={($vCDDrive.IsoPath)}}, @{L='HostDevice';E={($vCDDrive.HostDevice)}}, @{L='RemoteDevice';E={($vCDDrive.RemoteDevice)}}, @{L='Connected';E={(((($vCDDrive).ExtensionData).Connectable).Connected)}}, @{L='StartConnected';E={(((($vCDDrive).ExtensionData).Connectable).StartConnected)}}, @{L='AllowGuestControl';E={(((($vCDDrive).ExtensionData).Connectable).AllowGuestControl)}}, @{L='Status';E={(((($vCDDrive).ExtensionData).Connectable).Status)}} } } } END { Disconnect-VIServer -Server $ComputerName -Confirm:$FALSE ; Remove-PSSnapin VMware.VimAutomation.Core } }