Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-15
7
Medium Priority
?
654 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 24

Accepted Solution

by:
Luciano Patrão earned 2000 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 24

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 24

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 24

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

If we need to check who deleted a Virtual Machine from our vCenter. Looking this task in logs can be painful and spend lot of time, so the best way to check this is in the vCenter DB. Just connect to vCenter DB(default DB should be VCDB and using…
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Teach the user how to use create log bundles for vCenter Server or ESXi hosts Open vSphere Web Client: Generate vCenter Server and ESXi host log bundle:  Open vCenter Server Appliance Web Management interface and generate log bundle: Open vCenter Se…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

927 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