Solved

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

Posted on 2010-09-15
7
649 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:mail2vijay1982
  • 4
  • 3
7 Comments
 
LVL 23

Accepted Solution

by:
Luciano Patrão earned 500 total points
ID: 33684232
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
 
LVL 4

Author Comment

by:mail2vijay1982
ID: 33689967
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
 
LVL 23

Expert Comment

by:Luciano Patrão
ID: 33690709
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 4

Author Comment

by:mail2vijay1982
ID: 33692686
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
 
LVL 23

Expert Comment

by:Luciano Patrão
ID: 33692982
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
 
LVL 23

Expert Comment

by:Luciano Patrão
ID: 33697058
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
 
LVL 4

Author Closing Comment

by:mail2vijay1982
ID: 33699879
Good answer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
When rebooting a vCenters 6.0 and try to connect using vSphere Client we get this issue "Invalid URL: The hostname could not parsed." When we get this error we need to do some changes in the vCenter advanced settings to fix the issue.
Teach the user how to configure vSphere Replication and how to protect and recover VMs Open vSphere Web Client: Verify vsphere Replication is enabled: Enable vSphere Replication for a virtual machine: Verify replicated VM is created: Recover replica…
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question