Get the VM from the list of virtual machines serial number?

Property.  I have been breaking my head against that for hours and finally gave up and ask me for help.  I have this function below that I found at http://www.peppercrew.nl/index.php/2011/04/get-virtual-machine-bios-serial-number/.

It works fantastic for an individual VM, however I have a list of 250 VMs that I need this information, because our management software requires a unique serial number for each virtual computer.

I tried to edit the script to import from a .txt file and information through a foreach loop and am just not having any success.  What I am doing wrong?

function Get-VMSerial{

$VMList = Get-Content C:\VMList.txt    foreach ($VM in $VMList){
        $VirtualMachine = Get-VM $vm.name

    param([VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl]$VirtualMachine)
 
    $s = ($VirtualMachine.ExtensionData.Config.Uuid).Replace("-", "")
    $Uuid = "VMware-"    for ($i = 0; $i -lt $s.Length; $i += 2)
    {
        $Uuid += ("{0:x2}" -f [byte]("0x" + $s.Substring($i, 2)))
        if ($Uuid.Length -eq 30) { $Uuid += "-" } else { $Uuid += " " }
    }
 
    Write-Output $Uuid.TrimEnd()}



}

How to watch your CSV?

You have a header of column in there? Something like

Name

VM1

VM2

In this case, you can change the last line

Get-VM (Import-CSV C:\VMList.csv | Select -ExpandProperty Name) | Select Name,BIOSNumber

Tags: VMware

Similar Questions

  • Get the list of virtual machine names and addresses IP to a specific folder

    I am trying to get a list of virtual machine names and the IP addresses of a specific folder in vCenter. The problem is that there are several files with the same name in different folders. I need to know how to specify the level folder higher in which lies the customer10 folder. Here is an example of my current script that pulls all the info from the virtual machine of all folders named customer10:

    Get-vm-location customer10 | Select Address Name,@{N="IP." E = {@($_.guest.) (IPAddress[0])}} |
    out-file c:\VM_IP_Addresses.csv

    The PowerSHell engine is to 'know' the function before you call it.

    Save the function in a .ps1 file.

    Point source then this .ps1 file. Make sure that you are placed in the directory where the .ps1 is stored, or use the full path

    PowerCLI C:\ >. ./GetFolderByPath.ps1

    Note that there is an empty space between the 2 points!

    Now you can call the function

    PowerCLI C:\ > Get-FolderByPath-path MYDC/myFolder. Get - VM | Select the name...

  • Get the list of virtual machines on an ESX host specific and dumping of .csv in a specific format

    I have problems to find a way to get a list of virtual machines on an ESX host specific and then he dumped to a .csv in the following format

    I use the get-vmhost esxhostname | Get - vm

    but everyhting else after, it is where I am lost...  I think the closest I had been posting the output with a goofy header and format 'vm1, vm2, vm3 "...

    name

    computer 1 name

    computer 2 name

    name of the machine 3

    to use for later use.  Any help would be appreciated.

    You must use the Select-Object cmdlet to specify more precisely the properties you want.

    The Export-Csv doesn't know how to manage the virtual computer object.

    Something like that

    Get-vmhost esxhostname | Get - vm | Select name. Export Csv.\report.csv - NoTypeInformation - UseCulture

  • Get the list of virtual machines on an ESX host specific AND of a specific folder...

    I'm trying to get a list of the virtual machines running on an ESX host specific, but also are located in a specific folder.

    I think it must be something like that below, but for now without success:

    Get-vmhost $esx_hostname | Get-vm-location (get-record $folder_name( )
    giving the error message: Get - VM: the input object cannot be bound to all the settings for the command EIThim because
    the command does not pipeline or entry and its own input stakeholders do not match any parameters that accept entries of pipeline of.
    Any thoughts?
    Thank you!
    Eric

    VMHost and folder use the Get-VM-setting position. You must select either using the Where-Object cmdlet filter. For example:

    Get-VMHost $esx_hostname |
    Get-VM |
    Where-Object {$_.Folder.Name -eq $folder_name}
    
  • Get the list of virtual machines, storage of data and VMDK / path by cluster

    Hi people,

    as I m new to such things, I m wondering if someone already has a few scripts work to gather a list of all virtual machines, its corresponding data store (s) and the path to the files VMDK (or at least the name of it) - I know that this part has already been resolved - found a couple of them ;-)

    But my problem is, I need this script drilled down by Cluster Edition or Datacenter Edition. As I said I m completely new for this CLI stuff and Don t have any idea how to solve this problem...

    See you soon

    Markus

    Luke, you are right. I should have tested.

    There is a downside to the ForEach command that I almost never use. Normally I use the Foreach-Object cmdlet and that works very well with pipeing the output to Export-CSV.

    Markus, you must use option 2 in this case.

  • looking for a script to the list of virtual machines by datastore

    Someone at - it a script that lists each data store, then the virtual machines that are on it. Or maybe the list all virtual machines and data store or data warehouses is located in the virtual machine?

    Thank you

    This should do the trick for you.  In fact, it extends the computer object complete virtual with a property data store so you can still search the other aspects of the virtual machine.

    Get-Datastore. WHERE-object {$_.} {Name - like "DMX *"} | {ForEach-Object

    $dsname = $_. Name

    $_ | Get - VM | {ForEach-Object

    $($_ | Add - Member MemberType NoteProperty-name of store data-value $dsname - PassThru) | Select-object Name, host, Datastore

    }

    }

  • I get the error message that my serial number is not valid...

    I had to uninstall acrobat adobe 8 and trying to reinstall, I get the error message that my serial number is not valid.

    Hi Owen,.

    Following link might help: https://helpx.adobe.com/creative-suite/kb/invalid-serial-number-cs4.html

    Kind regards

    Rahul

  • How to import the list of virtual machines to complete a table in a workflow

    When you run the followingworkflow/library/vCenter/batch/run a workflow on a selection of objects

    How import you a list of virtual machines to complete the table of virtual machines?

    At this moment we are manually by selecting the virtual machines and adding them to the table individually which is very tedious. We would simply import a list.

    There is a certain ways that you can do what you're trying to do, but from your description, it looks like a wrapper will work best.  I enclose a simple workflow that loads the table from a csv file.  There is no error checking going on, but it should help you get started and you can expand on it from there.

  • Create the list of virtual machines to exclude the script through .csv file?

    Hello

    I have a script that runs all day off hours to check my VMs respect some things, like having the option to 'VM tools upgrade policy' checked. The script will export a list of virtual machines that DO NOT have this option enabled and then later to fix the problem. Now, for some specific VMS, I don't want to have the option active and want to exclude them from this review. I try to add a list of these virtual machines I want to exclude from my check script of VMTools_UpgradePolicy via a .csv file containing their names. Here's what I have:

    ##############################################
    #VMTools update during the feeding cycle - report
    ##############################################
    function Report_VMTools_UpgradePolicy {}
    $list = import-Csv "C:\VMware\PowerCLI\Scripts\EXCLUDE LIST\EXCLUDE_vmtools_upgradepolicy.csv".
    foreach ($entry in $list) {$exclude = Get-VM-name $entry. Name}
    $vms = get - Vm | where {$_.} Name - not $exclude - and (Get-View-Id $_.) {ID). Config.Tools.ToolsUpgradePolicy - eq 'manual'} | Select name
    $vms | Export-Csv "C:\VMware\PowerCLI\Scripts\REPORTS\vmtools_upgradepolicy.csv" - NoTypeInformation
    }

    The content of the EXCLUDE_vmtools_upgradepolicy.csv is as follows:

    'Name '.
    "VM1.
    "VM2.

    "VM3.

    I try to get all the virtual machines in my environment who have the ToolsUpgradePolicy - eq 'manual' (unchecked), AND which do not match any of the names on my list of exclusions (VM1, VM2, VM3). My script so far will do what I want, except that only the last entry in my list of exclusions will take into account. VM1 and VM2 will still be reported as VMs that need to be addressed.

    I'm not sure that I am taking the right approach with this, I will continue to seek a solution for what I want, but any help would be appreciated! I prefer to make my list of exclusion to a separate file, for example "EXCLUDE_vmtools_upgradepolicy.csv", because I want that other administrators to be able to just open this .csv file and add virtual machines to this list without having to touch my scripts.

    Thank you!

    Vince

    Hi Vince,.

    It is like that I think because of your statement:

    foreach ($entry in $list) {$exclude = Get-VM-name $entry. Name} -> it
    $vms = get - Vm | where {$_.} Name - not $exclude - and (Get-View-Id $_.) {ID). Config.Tools.ToolsUpgradePolicy - eq 'manual'} | Select name
    $vms | Export-Csv "C:\VMware\PowerCLI\Scripts\REPORTS\vmtools_upgradepolicy.csv" - NoTypeInformation
    }

    $exclude is a variable that contains only 1 entry., that's why you see only the last element inside. It will not be an array.

    foreach ($entry in $list) {[string []]+ $exclude = Get-VM-name $entry.} Name}

    This will fill $exclude table with entries of string that will contain the names of virtual machine.

    And when you will be comparing. I think you should use

    where {$exclude - notcontains $_.} Name - and... the rest

    Kind regards

    Greg

  • Script to stop and remove the list of virtual machines?

    Hello

    I would use powercli to stop and delete a list of virtual machines to a .csv file.  Although not quite clear on how to do it, can someone help out me?

    Hello, max08-

    Simply use this CSV as a list of names of virtual machine to stop and delete permanently, you can do something like:

    Import-Csv remove.csv | %{Stop-VM $_."Server Name" -Confirm:$false | Remove-VM -DeletePermanently -Confirm:$false -RunAsync}
    

    Note, it is non-interactive once you run - he doesn't want to stop the virtual machines or remove the disc, it does just.  So, make sure that the .csv file is only virtual computer names you really want to kill.

    How does do for you?

  • How to obtain the list of virtual machines in a cluster with the specific name

    Get-Cluster "Group 1" | Get - VM | where {$_.name - eq "owp *"} | Select name

    I've tried to filter the virtual machines with a specific name of a cluster by using a single command line but I am not going do anything...?

    I get results if I just Get-Cluster "Cluster 1' | Get - VM, but I want excluded other virtual machines to help to be enjoyed.

    Use - as instead of-eq

    Get-Cluster 'Cluster 1' | Get-VM | where {$_.name -like "owp*"} | select name
    
  • The list of virtual machines, data warehouses and the folder name by cluster


    Hello!!  I hope someone can help me with a PowerCLI script that can pull the info from the object into a file, txt or csv.  In order to get our environment cleaned before our next year Dr. with MRS, I want a list showing each VM and the data store (s) in that it is the name of the folder in the virtual computers view and models.  We keep our VMs organized by creating folder names that correspond to the application running on the virtual machine.  I mention a SRM than last year because our protected groups matched groups of our table of 3PAR Rcopy.  However, we have added over 200 new virtual machines from this era and the members of my team essentially placed these new virtual machines on the first available data store that had enough free space.  Unfortunately, we are not using storage profiles... it's scheduled for next year.

    Information extracted would look like the following:

    ServerName Datastore folder name

    Server1 LUN0 ActiveDirectory

    Server2 LUN0 ActiveDirectory

    Serveur3 LUN1 ActiveDirectory

    Server4 LUN3 Argo

    Server5 LUN7 Argo

    LUN6 Lockbox Server6

    LUN5 Lockbox Server7

    Serveur8 LUN9 Citrix

    etc...

    Any help with the extraction of this info from vCenter would be greatly appreciated.

    Thank you

    Charles

    You can redirect the results to a CSV file, for example

    Get-VM |Select Name,@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},@{N="Folder";E={$_.Folder.Name}} |Export-Csv C:\report.csv -NoTypeInformation -UseCulture
    
  • Match each data store its Lun ID and the list of virtual machines in each data store

    Hello

    Can anyone help? I'm looking to create a report that will show each Monday name and store data to data warehouses, the list virtual machines belonging to the storage of data and the name of the VCenter at the top of the report. I tried several combinations but was more difficult to get the Monday. Any help appreciated gratefully.

    Thank you

    If you use only LUNS is an easy way to get the canonical name:

    Get-datastore. {Select-Object Name,@{Name="CanonicalName"; expression = {$_.extensiondata.info.vmfs.extent.diskname}}

    I don't understand your requirement regarding the name vCenter, but for everything else

    Get-datastore. foreach {($MyDatastore = $_)} | Get - vm | Select-Object @{Name="Datastore";expression={$MyDatastore}},@{Name="CanonicalName";expression={$MyDatastore.extensiondata.info.vmfs.extent.diskname}},Name

  • Try the list of virtual machines by NetworkName, then add advanced settings

    Hello

    I'm trying to connect to a host (not a vCenter), list the virtual machines, select the different networks of those in two, then apply two advanced settings for the virtual machine.

    So far, I have this:

    $vms = get - VM

    SE connect-VIServer $esxi - user $user-password $pass

    {foreach ($vm to $vms)

    If (Get-NetworkAdapter - vm $vm.name |?) {{$_.NetworkName - eq "VLAN70"})}

    New-AdvancedSetting $vm - isolation.tools.copy.disable name-set to false - confirm: $false - Force: $true

    New-AdvancedSetting $vm - isolation.tools.paste.disable name-set to false - confirm: $false - Force: $true

    }

    }

    Disconnect-VIServer $esxi - confirm: $false

    First of all, how I add a second network to verify - if 'VLAN70' or 'VLAN80 '?

    Secondly, there is a smarter way of writing this script?  I'm doors beginning with PowerCLI, but I think even my grandmother could write a better version...

    Any advice would be greatly appreciated,

    -virtualhobbit

    I see, so you could do something like this

    $tgtVLAN = "VLAN80", "VLAN80", "VLAN90".

    SE connect-VIServer $esxi - user $user-password $pass

    Get - VM |

    where {(Get-NetworkAdapter-VM $_ | % {$tgtVLAN-contient $_.NetworkName}) - contains $true} | %{

    New-AdvancedSetting $_ - isolation.tools.copy.disable name-set to false - confirm: $false - Force: $true

    New-AdvancedSetting $_ - isolation.tools.paste.disable name-set to false - confirm: $false - Force: $true

    }

    Disconnect-VIServer $esxi - confirm: $false

  • PowerCLI Script to the list of virtual machines by their hosts

    Trying to find a simple script that will display a list of virtual to a CSV file and computers are that they currently host slot, but not lucky so far. Closer, I found is that of Alan Renouf below that lists the number of VMs per host, but not the actual names.

    Get-VMHost | Select @{N=“Cluster“; E={Get-Cluster -VMHost $_}}, Name, @{N=“NumVM“; E={($_ | Get-VM ). County}} | Sort Cluster, Name | Export-Csv -NoTypeInformation c:\clu-host-numvm.csv

    I'm sure it's something in the simple sense of get-vmhost | Get - vm, but should the listed host. Any ideas?

    Hello, Viewaskew-

    There is a property, VMHost, of computer virtual objects.  For example, you can use a Get - VM call forwarded to a Select-Object statement (then to Export-Csv), as:

    Get-VM | Select Name,VMHost | Export-Csv -Path c:\temp\VMsAndHostsInfo.csv -NoTypeInformation -UseCulture
    

    What to do for you?

Maybe you are looking for