Need to identify the Serial port which are enbled on VM at single shot

HI Experts,

I have got request to remove the Serial port on Virtual machin, Actually we have around 350 VM most of the VM's are enabled Serial port some of them are not enabled, so how do we find which are the Vm's  have serial port enable and how do we remove at one shot.

Many Thanks,
Vijay.
LVL 4
Vijay kumar MohanrajCloud ArchitechAsked:
Who is Participating?
 
Luciano PatrãoConnect With a Mentor ICT Senior Infraestructure  Engineer  Commented:
Hi

Hope this can help you

I think this script can show you the information that you need

Also you can try to use vminfo.pl from vSphere SDK to extract this values

Hope this can help you

Jail
#########################################################################################
# The script lists information about CD-ROM, Floppy, Parallel Ports and Seriel Ports   	#
#  										      									       	#
# Created by: Anders Mikkelsen, 2009			 	     	                     		#
#########################################################################################
Add-PSSnapin VMware.VimAutomation.Core

$server = "VIServerName or IP"
$user = "UserName"
$pwd = "Password"

Connect-VIServer $server -User $user -Password $pwd

$vms = Get-VM
write "VM's with CD-ROM 'Connected' :"
foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.ConnectionState.Connected -eq "true"}}) {
	write $vm.name
}
write "`nVM's with CD-ROM set to 'Connect at power on' :"
foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.ConnectionState.StartConnected -eq "true"}}) {
	write $vm.name
}

write "`nVM's with CD-ROM device type set to 'Client Device' :"
foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.RemoteDevice.Length -ge 0}}) {
	write $vm.name
}

write "`nVM's with CD-ROM device type set to 'Datastore ISO file' :"
foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.ISOPath -like "*.ISO*"}}) {
	write $vm.name
}

write "`nVM's with Floppy 'Connected' :"
foreach ($vm in $vms | where { $_ | Get-FloppyDrive | where { $_.ConnectionState.Connected -eq "true"}}) {
	write $vm.name
}

write "`nVM's with Floppy 'Connect at power on' :"
foreach ($vm in $vms | where { $_ | Get-FloppyDrive | where { $_.ConnectionState.StartConnected -eq "true"}}) {
	write $vm.name
}

write "`nVM's with Floppy device type set to 'Client Device' :"
foreach ($vm in $vms | where { $_ | Get-FloppyDrive | where { $_.RemoteDevice.Length -ge 0}}) {
	write $vm.name
}

write "`nVM's with Floppy device type set to 'Use excisting floppy image in datastore' :"
foreach ($vm in $vms | where { $_ | Get-FloppyDrive | where { $_.FloppyImagePath -like "*.FLP*"}}) {
	write $vm.name
}

write "`nVM's with Serial Ports attached :"
$vms | Get-View | %{
  foreach($dev in $_.Config.Hardware.Device){
    if($dev.DeviceInfo.Label -like "Serial Port*"){
	  foreach($tmp in $dev.Connectable){
	    write $_.Name 
	    #write $tmp
	  }
    }
  }
}

write "`nVM's with Parallel Ports attached :"
$vms | Get-View | %{
  foreach($dev in $_.Config.Hardware.Device){
    if($dev.DeviceInfo.Label -like "Parallel Port*"){
	  foreach($tmp in $dev.Connectable){
	    write $_.Name 
	    #write $tmp
	  }
    }
  }
}

Open in new window

0
 
Vijay kumar MohanrajCloud ArchitechAuthor Commented:
HI

this script is descried only one Vm, we can check cd-rom,serial port,etc, But How can i find the 350 Vms at the same time.
0
 
Luciano PatrãoICT Senior Infraestructure  Engineer  Commented:
Hi

No. You need to connect this scrip to your vCenter, or ESX host.

Also if you use the vminfo.pl, you need to connect to the vCenter or ESX host.

Of course you need to change the Script and add your vCenter credentials

$server = "VIServerName or IP"
$user = "UserName"
$pwd = "Password"

Jail
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
Vijay kumar MohanrajCloud ArchitechAuthor Commented:
HI BestWay,

Thanks for the replay,

My question is how do we find the serial port for 300 Vms,This script is for finding serial port for only one Vm, not for 300 Vm.
0
 
Luciano PatrãoICT Senior Infraestructure  Engineer  Commented:
Hi

This script will run on the vCenter configuration(this is why you need to connect to the vCenter with the script) and will check all the VMs inside of that vCenter one by one and give you the information for all the VMs

You need to add you vCenter information like i show in my last message. Change the script(that 3 options) with your configuration. servername or IP, user and password to connect to vCenter)

Jail
0
 
Luciano PatrãoICT Senior Infraestructure  Engineer  Commented:
Hi

Now i have some time and tested the script, and this what i get when run the script on a vCenter LAB that i have.

As you can see, it scans all the VMs to check, CD-ROM, ISO Datastore, Floppy, Parallel Port, Serial Port, etc., then shows what VMs are using each of this settings.

With this you can get all the information that you need.

So like i said, you need to change the script and add your vCenter or ESC host IP, user and password, and run this on the Powershell console(or PowerGui Editor).

Jail


Name                                         Port                                         User                                       
----                                         ----                                         ----                                       
192.168.1.40                                 443                                          administrator                              
VM's with CD-ROM 'Connected' :

VM's with CD-ROM set to 'Connect at power on' :
ESX 4.1.0-260247
VM Brightstor
vSphere Management Assistant
ESX 4.0.0-164009
ESX 4.0.0-u1-208167
VM Linux Oracle
VM XP Pessoal
VM Exchange 2007
VM DC 2008 Lab
VM ORACLE
VM HYPERION

VM's with CD-ROM device type set to 'Client Device' :
VM Win 7 Pro
VM LAB
VM Testing ISA
vCenter Lab Hosts
VM Clone
VM DC

VM's with CD-ROM device type set to 'Datastore ISO file' :
ESX 4.1.0-260247
VM DC Lab
VM Brightstor
ESX 4.0.0-164009
ESX 4.0.0-u1-208167
VM Linux Oracle
VM Exchange 2007
VM DC 2008 Lab
VM ORACLE
VM HYPERION

VM's with Floppy 'Connected' :

VM's with Floppy 'Connect at power on' :

VM's with Floppy device type set to 'Client Device' :

VM's with Floppy device type set to 'Use existing floppy image in datastore' :

VM's with Serial Ports attached :

VM's with Parallel Ports attached :

Open in new window

0
 
Vijay kumar MohanrajCloud ArchitechAuthor Commented:
Good answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.