The value of VM = DNS name

Morning he

I have been using the script with great success but who want to see if it could be refined below. What I intend to do is to say rename all VMs with different names BUT exclude any virtual machine whose DNS name contains 'local; TMP'

The reason is that we have many instances where devices of vmware gets deployed where the hostname is localhost and details of vApp is the descriptive part.

Current script:

Connect-VIServer # MyvCenterSRV

# State whether your virtual machine names the FQDN

$IncludeFQDN = $false

Get-VM | { $_. {PowerState -eq 'Receiving' } | Foreach {

    If ($IncludeFQDN) { }

$Name = $_. Guest.Hostname

} Else {}

$Name = (([string]$_. (Guest.HostName). Split (".")) [0]

}

If ($_. {(Nom -ne $Name)}

If ($_. Guest.Hostname) {}

            Write "Name VM ' $($_.)" Name) "" is not the same as the $Name hostname ""

  Set-VM $_. Nom -nom $Name - whatif -confirmer:$false

} Else {}

Writing "Unable to read hostname $ ($_.). (Name) - no VMTools? »

}

}

}

Proposed changes:

Connect-VIServer # MyvCenterSRV

# State whether your virtual machine names the FQDN

$IncludeFQDN = $false

$excludeNAME = localhost, TEMP... (Do not know where to call them that)

Get-VM | { $_. {PowerState -eq 'Receiving' } | Foreach {

    If ($IncludeFQDN) { }

$Name = $_. Guest.Hostname

} Else {}

$Name = (([string]$_. (Guest.HostName). Split (".")) [0]

}

If ($_. {(Nom -ne $Name)}

If ($_. Guest.Hostname) {}

            Write "Name VM ' $($_.)" Name) "" is not the same as the $Name hostname ""

  Set-VM $_. Nom -nom $Name - whatif -confirmer:$false

} Else {}

Writing "Unable to read hostname $ ($_.). (Name) - no VMTools? »

}

}

}

Hope someone have a suggestion.

Thank you

Johan

Try something like this

#Connect-VIServer MyvCenterSRV# Specify if your virtual machine names include the FQDN$IncludeFQDN = $false$excludeNAME = "localhost|TEMP"

Get-VM | Where { $_.PowerState -eq "PoweredOn" } | Foreach {  If ($_.Guest.Hostname) {    If ($IncludeFQDN) {      $Name = $_.Guest.Hostname    } Else {      $Name = (([string]$_.Guest.HostName).Split("."))[0]    }    If ($_.Name -ne $Name -and $Name -notmatch $excludeNAME) {      Write "VM name '$($_.Name)' is not the same as the hostname $Name"      Set-VM $_.Name -Name $Name -whatif -confirm:$false    }  }  Else {    Write "Unable to read hostname for $($_.Name) - No VMTools ?"  }}

The script uses an expression (operator of match) RegEx to check if the hostname does not contain 'localhost' or 'TEMP' (the vertical bar in the string is the part of GOLD)

Tags: VMware

Similar Questions

  • Dependent on the value of query column names

    Hi guys, I don't think this is possible, but I thought I'd give it a go.

    I am wanting to values that are returned by my query as column headings. For example:

    SELECT 1,2,3,4,5
    OF trade_table
    WHERE < 6

    The table contains 10 records, "A1", "B1", "C1", "D1", "E1", "F1" etc... and my query returns 5 records of each with a rating of 1 to 5. The first record in the standings, lets say "D1" must be the column heading.

    I'm extremely sorry for being vague, but my request first contains a lot of analytical functions and I try to simplify it.

    Thanks in advance.

    To do this with the reporting you tool use and not with SQL and PL/SQL.

  • Sustaining the values of point unchanged after a "set-point and redirect.

    I use the instance online on apex.oracle.com

    I have a form that looks like this:

    Name: < text field >
    Type: < select list >
    Property1: < select list >

    When Type is changed, a "set-point and redirect" are performed.

    The source of Property1 is determined by the value of Type. This means that whenever the Type is changed, the Property1 value could change.

    'Name' is not affected. The problem is when I change the 'name' and then change 'Type', the action "Set the value and redirect" returns 'Name' to the value it had when the first load of the page.

    The question is: is it possible to ensure that the 'name' retains some value it had just before "the set value and redirect" was carried out?

    Thank you.

    popovitsj wrote:
    I use the instance online on apex.oracle.com

    I have a form that looks like this:

    Name:
    Type:

    When Type is changed, a "set-point and redirect" are performed.

    The source of Property1 is determined by the value of Type. This means that whenever the Type is changed, the Property1 value could change.

    'Name' is not affected. The problem is when I change the 'name' and then change 'Type', the action "Set the value and redirect" returns 'Name' to the value it had when the first load of the page.

    The question is: is it possible to ensure that the 'name' retains some value it had just before "the set value and redirect" was carried out?

    Create it Type and Property1 by using the ability of LOV cascade integrated rather than try to to re-create yourself.

  • Getting the value of field of a cake clicked on slice in a pie chart?

    I tried and have searched for hours and can't get this simple trick to work.

    I have a pie with the following event handler:

    itemClick = "chart_click (event)" "

    The pie series comes from a simple httpservice which has a country and a count:

    < mx:PieSeries
    field = 'count '.
    field name = 'value '.
    labelPosition = "legend."
    calloutGap = '5 '.
    labelFunction = "show".
    showDataEffect = "{interpolate}" >

    All I want to do is capture the value of the name field (EG: Canada)

    I have no problem to get the index of the selected series, but I can't get the value of this group name field. That's what I have:

    public void chart_click(e:ChartItemEvent):void
    {
    Alert.Show (searchByPieChart.Series, [e.hitData.chartItem.index], .nameField);
    }

    All I get is the 'value' string that is the name of the xml tag bound to the name field. What should I do?

    UGGG.

    I got it:

    Alert.Show (e.hitData.Item.value);

  • read the value of the variable knowing only one name

    Is there a way to read a variable value of knowing only the label name? I have 11 Labview and am to read a text file with a list of variable labels and try to read the value without having to create a structure of matter of hundreds of variables.

    Are we willing?

  • How to get a program all the list of the names of the values in a registry key?

    Hello

    How to get a program all the list of the names of the values in a key of windows registry without having to configure the number of values in the key?

    Thank you & best regards

    Samuel J

    Hi Samuel,.

    you will get this info from "Query registry key Info.vi".

    Mike

  • Send the name and the value of the control to Subvi

    Hi all

    I am trying to send the names and values of the controls to a Subvi.

    I know that I can check out the name and the value of the control by using a property node, but I was looking for a way to make is easy for the programmer to use.

    I think some sort of bundle function, it records the name and the value of the control, but I would like the programmer to be able to connect a random number

    controls to the Subvi without having to specify the number of controls Anywhere.

    I know there is stuff in labview configuration file, but it seems a bit more complex, so what I want to do.

    Also, I know that I can use the OpenG toolkit, but I will not use additional LabVIEW modules, as this VI may run on several different computers.

    I hope I made my problem clear enough!

    Good day

    Concerning

    Tommy

    What, creating an array of references to the command.  On the hand, you will need to fill the table with control references that you want to send to the Subvi.  In the Subvi, use a loop For with indexing to get every reference, and then use the nodes property to get the name and value.

  • Displaying an Enum value and the name of the element when the values are not sequential

    Hello

    I use Enum and controls indictators successfully with shared and modbus variables.

    For example:

    Name of the element Value

    Off:                0

    Start 1

    On                2

    Œuvres enum Setup, I don't need to look for a cheat sheet to convert the name of the element in its value, I see the name of the item in my order/indicator.

    My new variables, I'm currently managing look like this:

    Name of the element Value

    Code 0 x 201

    Beginning Code 0 x 202

    Code 0 x 001

    Any ideas how I can display the value and the name of the element on a façade. (for a control and indicator)

    For enumerations, it seems that the item values must go 0,1,2,3,4,5

    I found the solution:

    http://digital.NI.com/public.nsf/allkb/79BA4505AE8C755E86256FB2000140B0

    use a ring of text and deselect the sequential box

  • Ring control output is the name of the item and not the value

    Hello. I'm new to Labview. I'm experimenting with labview and create just simple VI to learn more about the software. I placed a control of the ring and attached an indicator to this control of the ring. I found that the object of a control ring to select an element and an output value. For example, I placed 3 items in the properties of the ring (red, blue, yellow) and given the value of these items 1,2,3. But when I run the VI and select blue, I was expecting the indicator attached to the control to read 2, but on the contrary, he says 'Blue' (even for other items). What I'm misunderstanding here or to hurt? I've also attached a screenshot.

    Your meter is another ring that has the same pair name / value, so it's going to see the name associated with the value.  Remove the ring indicator and just drag in an ordinary digital indicator.  Then, it will show you the value.

  • [.ini files] Get the value of multiple labels with the same name

    Hello!

    In an ini.files, I need to get the value of each tag named in a certain way in a section, but unfortunately, I have 3 or 4 tags with the same name in several sections. I don't know how to retrieve these values, the program always consider that the first tag and not others, I tried to remove each tag after obtaining its values, that he did not.

    Does anyone have an idea to solve the problem?

    Thank you!

    As you can read in my last post, you must read and throw 'x' lines:

    OpenFile)

    Skip lines

    for (i = 0; i< x;="" i++)="" readline="">

    Start reading the useful lines

    ReadLine () / / read a line

    ... / / Interpret the line

    Don't forget to add a control during i/o operations of robust error and to check the end of the file.

  • A Remote Assistance connection could not be established because the DNS name of the remote computer could not be resolved

    I am trying to use remote assistance to help with my brothers computer. We both use XP, but when I try to open remote assistance to view and or even take control of his computer, I get an error message: connection A Remote Assistance could not be established because the DNS name of the remote computer cannot be resolved. Why this might be happening?

    Hello

    It depends on how the computers are connected and their intellectual property regime.

    They are on the same network (e.g., connected to the same router)?

    Through the Internet? Something else?

    http://support.Microsoft.com/kb/300546/en-us

    Jack - Microsoft MVP, Windows networking. WWW.EZLAN.NET

  • I am trying to accept an invitation from my mom's remote assistance and this is what I got after entering the password: connect Remote Assistance could not be established because the DNS name of the remote computer cannot be resolved.

    I am trying to accept an invitation from my mom's remote assistance and this is what I got after entering the password: connect Remote Assistance could not be established because the DNS name of the remote computer cannot be resolved.

    You get the error "a Remote Assistance connection could not be established because the DNS name of the remote computer could not be resolved" when the requesting computer (the computer 'demand' help) sends its private IP address instead of its public IP address in the request for assistance. The solution is 'easy' for some and difficult for others. I present here for your perusal:

    (1) obtain the public IP address of the requesting computer (by visiting a web page such as http://www.whatismyip.com)
    (2) save the remote assistance request computers
    (3) modify the remote request for Assistance (RcBuddy.MsRcIncident) using a text editor (such as notepad) and replace the private - section of IP address should be something like this:
    RCTICKET = 65538,1,192.168.1.33:3389 «»
    with the public IP address from whatismyip.com or elsewhere - should be something like this:
    RCTICKET = 65538,1,74.125.47.147:3389 «»
    (4) save the file of RcBuddy.MsRcIncident 'new '.
    (5) double click it to connect to the computer needing help
    (6) cross your fingers and hope it works!

    I hope this helps someone else - if it's too much trouble, feel free to use the tools mentioned elsewhere in this thread.

    -Computers Acorp
    www.ACoRP.net

  • Unable to join the domain "DNS name does not exist."

    Working on this computer remotely in my company, it has more a problem but at this moment, that we focus on trying to reach the area. We removed everything first to see if it would fix the trust relationship issues she felt the long side not being able to browse the files all computer network or servers.
    When trying to join the field, that's what we get in the dcdiag.txt in the debug folder.
    The domain name 'xxxxx' can be a NetBIOS domain name.  If this is the case, check that the domain name is properly registered with WINS.
    If you are certain that the name is not a NetBIOS domain name, then the following information can help you troubleshoot your DNS configuration.
    The following error occurred when DNS was questioned about the resource record (SRV) service location used to locate an Active Directory (AD DC) domain controller for the domain "xxxxx":
    The error was: "the DNS name does not exist."
    (0x0000232B RCODE_NAME_ERROR error code)
    The query was for the SRV record for _ldap._tcp.dc._msdcs.xxxxx
    Common causes of this error are:
    -The DNS SRV records to locate an AD DC for the domain are not registered in DNS. These records are automatically saved with a DNS server when an AD domain controller is added to a domain. They are updated by the AD DC at set intervals. This computer is configured to use DNS servers with the following IP addresses:
    198.6.1.5
    198.6.100.38
    -One or more of the following areas do not include delegation to its child zone:
    XXXXX
    . (the root zone)
    XXXXX = domain
    Also the listed IP addresses have been changed.

    I worked on this computer for about 2 days, and then the user is able to work remotely with a server terminal server, they will need access to the server later.

    Reset the network device - completely.  Uninstall the network driver and have someone there install the latest manufacturer.

    Manually enter the DNS information for the DNS servers of your company on the computer - even if it uses DHCP.

    Make sure that its time/time zone is the same as your DNS server.

    Reset all default HOSTS file.

    Ping the DNS server.

    When you join - use the FQDN (mycompany.local, etc..)

  • Read the value of XML or JSON based on the name of the key

    I can't figure out how to get the value of the url to Image_Calendar1 JSON or XML data.  Sorry if it's 'obvious', but I am a new developer.

    I was cheating and ListItemData.value [1] .url but in this case, that the XML feed changes the number values of the moments which throws out of my method.  I need to be able to get the value based on the name of the key.  Is this possible?

    Thank you. Examples of the XML and the JSON /port.

    Okay, it might not be pretty, but what I do to solve my problem is to convert the ListItemData in JSON and stringify it.  I then split the string with 'key' and then count the lines.  Would not work if 'key' wasn't in each line, or if there are child elements of the child elements.  But... it works for me at the moment.  Future, me I hope, will be more intelligent and can fix it when it breaks.

    var testString = String (JSON.stringify (ListItemData))

    var javascriptcount = String (testString.split("key").length - 1).

    Console.log ("try to use the length:" + javascriptcount)

  • Name of the dynamic property of object in the table based on the value of a variable

    I have two paintings of custom class objects

    var obj1:Object1
    var obj2:Object2
    
    var array1:Array = [obj1[0], obj1[1], ...]
    var array2:Array = [obj2[0], obj2[1], ...]
    

    Object1 has a property named. Name while Object2 has a property named. Title.

    Now I have a common function including cab accepts an array (array1 or array2) and the name of property the object ("Name" or "Title") as input and needs to access this name of the property of the objects in the array:

    function myFunction(arr:Array, fieldName:String)
    {
        arr[0].fieldName  = "xxx";
    }
    

    the problem I have this achievement does not because the code in the function assumes that the property of that object in the table is actually a string "fieldName" while I want to dynamically determine the names of the fields based on the value of this variable, but cannot understand the syntax to do!

    Don't know if I'm clear - hope that makes sense... ;-) Thank you

    Hey p3pp3r,

    I think I understood you. Try the following and see if you get good results:

    function myFunction(arr:Array, fieldName:String)
    {
        arr[0][fieldName]  = "xxx";
    }
    

    Let me know how it turns out. Good luck!

Maybe you are looking for