Script to change the name of the file to the virtual machine and its associated files

Hello

I'm looking for a script to change the name of the virtual machine in virtual center and also change it has associated file names in the data store to match file name of virtual machine. But the vmdk file will contain a descriptor which maps the - flat.vmdk file. So not sure that we can achieve this through a script.

Thanks in advance!

Not really as much as I know.

The advantage of the svMotion is renamed it the files (.) VMX, VMDK,...) For you.

The only alternative would be the command line. See Duncan Howto: renaming a virtual computer.

With the help of the plink.exe tool which could possibly be scripted.

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • Get the IP of the virtual machine and MAC

    Hello

    I'm trying to get the IP of the virtual machine and the MAC one of my data centers.

    When I run that the following script two things happen:

    1. I don't see a vm in the output of the csv file.

    2. when I send the output to the quick PowrCLI I see only a mac and one IP address for virtual machines with network cards.

    Script

    ---------

    $MV = Get-Data Center $DC | Get-vmhost | Get - VM

    {foreach ($VM to $VMs)

    $VMx = get-view $VM.ID

    $HW = $VMx.guest.net

    foreach ($dev to $HW)

    {

    foreach ($ip in $dev.ipaddress)

    {

    $dev | Select

    @{Name = 'Name'; {Expression = {$vm.name}}.

    @{Name = 'IP address'; Expression is {$ip}},

    @{Name = 'MAC'; {Expression = {$dev.macaddress}} |

    Export-CSV VM - IP - Info.csv - NoTypeInfo

    }

    }

    }

    My console output, tested on a virtual machine with two external network cards and an internal interface "dummy".

    Name                               IP                                  MAC

    ----                                   --                                    ---

    VM1 192.168.1.1 00:50:56:xx:xx:xx

    VM1 192.168.2.1 00:50:56:xx:xx:xx

    VM1 192.x.x.xxx xx

    You see the addresses expected in summary using vSphere Client VM?

    Oh sorry, I forgot the PS 3.0 requirement.

    You can put all the entries in a table and export all at the end of the script.

    $out = @)
    $VMs = get-data center $DC | Get-vmhost | Get - VM
    {foreach ($VM to $VMs)
    $VMx = get-view $VM.ID
    $HW = $VMx.guest.net
    foreach ($dev to $HW)
    {
    foreach ($ip in $dev.ipaddress)
    {
    $out += $dev. Select @{Name = 'Name'; {Expression = {$vm.name}}, @{Name = 'IP address'; Expression = {$ip}}, @{Name = 'MAC'; {Expression = {$dev.macaddress}}
    }
    }
    }

    $out | Export-Csv - NoTypeInformation-Path ' VM - IP - Info.csv.

    Concerning

    Emanuel

  • I get an error "the disk hard virtual parent is in a saved state. Discard the saved state or stop the virtual machine and try again. "during the installation of XP mode.

    I have Win7 Pro SP1 x 64.  I downloaded WindowsXPMode_en - us.exe (from Microsoft downloads) and run it.  The installation seems to work OK (I've specified a different location for the parent virtual hard disk file).  Then, installation happening and I provide the information requested (name of user and password for the XP Mode), updates Windows and OK to the issue of sharing.  The installation program then reports the following error:

    The disk hard virtual parent is in a saved state.  Discard the saved state or stop the virtual machine and try again.

    I get the error even if I try manually configure XP Mode (use the Setup Wizard).  I downloaded the installer XPMode (3 times) and reinstalled several times, always with the same result.  If it helps, I can't locate anywhere .vsv file.

    Any idea what's going on?

    Original title: XP Mode Setup error

    Hi smithnr10,

     

     

    You must post your question in the TechNet forums because it caters to an audience of it professionals.

    To do this, you must consult the link-

    http://social.technet.Microsoft.com/forums/en-us/w7itprovirt/threads

     

    Hope this helps!

  • Connect physical hard disks to the virtual machine (and leave the data intact)

    Hello

    I'm looking to virtualize a SOHO headless server, that I use mainly for secure file storage.

    Currently, the system runs Linux installed on a small disc and has two drives 1.5 TB, used exclusively for data, in a cluster of ZFS mirroring. (I use the ZFS-fuse Linux-based application).

    I want virtualization for two reasons. One is to make administration easier and safer - avoid having to connect a keyboard and the physical monitor to the box from time to time. The other is that the machine is a bit more powerful to handle the load, and I'm hoping to make it work on other, more challenging tasks.

    Now, there is a catch. These discs are as highly important. I mean the data on them. What I need is to convert the current Linux system to a virtual machine, or re - install Linux on a virtual machine (don't like that), then connect the physical disks to the virtual machine as if they were actually connected.

    I certainly don't want to vmware touches those disks somehow.

    I've read the documentation, but I'm a noob when it comes to server virtualization and system engineering and don't quite understand if this is possible or not. These discs are not a SAN, they are physically connected to the server, I want to install vSphere on. (Of course, I'll log out when I run the setup of vSphere. But I need plug them again later, and they need to be sure that vmware will leave them alone and pass them to the virtual machine transparent.)

    Sigmoid wrote:

    Oh yes, the cluster mirrored ZFS. It is essentially a software RAID type thingie.

    http://en.Wikipedia.org/wiki/ZFS

    A material, or the point of view of virtualization, it appears two hard drives with a single huge partition on each that is not transparent to anyone, except the implementation of ZFS.

    OK, means that you can break the RAID, connect the drives to different host and configure RAID once again, right?

    Let's do it this way

    1. We will need a disc player more for VM, cause on flash, we install ESXi
    2. I will share ZFS :-), all you need to do with that before you install ESXi
    3. make the BACKUP!
    4. Disconnect the data host drives
    5. install ESXi 4.1 U1 free version on flash
    6. Download the site VMware vSphere client
    7. Connect the VM disk to ESXi
    8. customer help create the virtual machine and install the OS on it
    9. stop the virtual machine and esxi
    10. connect DATA drives to the ESXi host
    11. begin to ESXi
    12. See how to add RDM on youtube, after client use, change first hardware VM--> add a new hard disk--> choose Raw Device Mapping--> (physical or virtual) mode--> store it with folder VM - FACT
    13. Start the virtual machine, now your VM should see both drives, with good data course :-)

    I have just made this procedure (add ROW with data in Linux VM) on ubuntu VM, works well

  • Start the Virtual Machine and stop Option

    Hi all

    I would like to know how to change the Virtual Machine start and stop through PowerCLI Options.

    I would like to change the default start time, the default close delay with a script, but I am not able to do...

    Someone knows how to do?

    Thanks for your help!

    Sorry, it's just realized that you wanted to say.

    See the Set-VMHostStartPolicy and Set-VMStartPolicy cmdlets.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • [Beginner] How to change the virtual machine name

    Hello

    How can I change the name of a Virtual Machine - I want to say the name that appears in VMPlayer (or VMWare Fusion) as it has recently used Virtual Machines. I tried to change the name of the vmx file but this does not affect the name of the virtual machine displayed in VMPlayer.

    Thank you very much.

    TomasBar wrote:

    How can I change the name of a Virtual Machine - I want to say the name that appears in VMPlayer (or VMWare Fusion) as it has recently used Virtual Machines.

    VMware Fusion 3.x and 2.x but not 1.x, you can click on and change the name of the virtual machine in the Virtual Machine library on the right side, just under the display area.

    For VMware Player you need to edit the "displayName ="parameter in the configuration file .vmx and of VMware Player virtual machine must be closed when you perform this operation."

  • script to stop the virtual machine

    I am writing a script to stop all the virtual machine as follows:

    1. The list of the VM

    VMLIST ='/ usr/bin/vmrun list '

    for a virtual machine in '$VMLIST '.

    do

    echo '$VM '.

    1. stop the virtual machine

    / usr/bin/vmrun stop '$VM' trysoft

    sleep 2

    fact

    But he failed, the news of the error:

    / root/vmware/Windows NT / Windows NT.vmx

    Error: Could not open the virtual machine: unknown suffixNT/Windows NT.vmx file

    the feedback by the command "echo $VM" is the correct path, but why it says file unknown?

    Please refer to the attachment.

    See if that helps...

    vmlist ='/ usr/bin/vmrun list '

    printf "$vmlist" | egrep '\.vmx$ ' | while reading vm; echo '$vm '.

    / usr/bin/vmrun stop soft "$vm".

    sleep 2; fact

  • Avalibale features in the free ESXi version - auto start the virtual machine and scripts shoutdown?

    Hey all,.

    Evaluating 60A expired on my ESXi (5.0.0.623860) host which runs a couple of virtual machines. Virtual machines have been setup to autostart when the host said, but now the assessment is complete, the virtual machine no longer autostart.

    In addition, I ran a simple scipt using PowerCLI. This was shot issue a stop host command, which in turn stop the gracfully VMs, then stop the host: the script command were:

    Connect-VIServer -server mysESXiHost -User root -Password xxxxxxx
    Stop-VMHost mysESXiHost -Confirm:$false -force
    

    If I run these commands from the PowerCLI confirmation, I see the following error message:

    Stop-VMHost : 08/12/2012 17:01:52    Stop-VMHost        fault.RestrictedVersion
    .summary
    At line:1 char:12
    + Stop-VMHost <<<<  mysESXiHost -Confirm:$false -force
        + CategoryInfo          : NotSpecified: (:) [Stop-VMHost], RestrictedVersi
       on
        + FullyQualifiedErrorId : Client20_VmHostServiceImpl_ShutdownVmHost_ViErro
       r,VMware.VimAutomation.ViCore.Cmdlets.Commands.StopVMHost
    

    What I read, I thought that current same ESXi of execution in the free license must always let these things happen, or am I wrong?

    Chris

    There are two things to note:

    (1) the fault of . RestrictedVersion.summary details can be found here http://www.virtuallyghetto.com/2011/06/dreaded-faultrestrictedversionsummary.html

    (2) regarding Auto Start, fairytale look here http://blogs.vmware.com/vsphere/2012/07/clarification-on-the-auto-start-issues-in-vsphere-51-update-1.html

  • Unable to start the virtual machine and snapshots are missing from snapshot Manager.

    Hello

    I'm new here in the VMWARE communities and I don't know if I'm posting this survey in the right place. I am currently using VMWARE Workstation 9. The issue I'm having is that I can not start my VM. The error that says:

    vm error.png

    This is an overview of my settings:

    settings.png

    When I try to get a snapshot I can go back, I get this snapshot Manager screen:

    snapshot.png

    I checked the files on the directory of the virtual machine. The snapshot files are still there.

    I tried to solve the problem by editing the configuration of virtual machine file to use another vmdk. I got an error saying something about the parent and the child are not synchronized. Sorry I don't have a screenshot of that. I also tried to make a copy of one of the other VMDK and rename it to match with the name of the missing file. That also made me anywhere I tried looking on the net but I get answers to other vmware ESXi and vSphere products. So I don't know if they apply to my current situation.

    At this point, I'm hoping to recover my machine or at least be able to use snapshots. Please notify.

    I think that the restoration was the best way to solve this problem. I actually checked the different files, but it looks like I missed something. In any case, create snapshots with the virtual machine in a state engine is my personal preference. It is not only to save disk space (since there is no need to preserve the current state of memory), but also provides a consistent state. As for the number of snapshots, you're always on the stop side, and if you are not having issue of performace with small changes you make you should be ok. In case there is a performance problem, you may consider to store the computer virtual on an SSD that will certainly help.

    Since the Center of Documentation of VMware Workstation 10

    To the premises of the virtual machines, you can take more than 100 snapshots for each linear process. For shared virtual computers and remote, you can take a maximum of 31 snapshots for each linear process.

    André

    Post edited by: a.p. corrected fault, "SSD" instead of "SD".

  • Automate the deployment of iso on the virtual machine and configuration following the

    I need to:

    1. create a virtual machine with a certain configuration

    2 specify an iso file to be connected to the power on.

    3. the need to have access to the console after plugging on.

    I know that #1 and #2 are possible using the CLI. I need to know if #3 is possible.


    I need to deploy a custom on the virtual computer operating system and must have access to the console to use options in the CLI of the target VM.



    TIA

    When you say that access to the console after poweron, do you mean open the console automatically? If this is the case, then you can use the Open-VMConsoleWindow cmdlet. It will automatically open the console of the virtual machine in WebClient.

    If you want to automatically run commands inside the virtual machine then use Invoke-VMScript cmdlet.

    Please let me know if this is what you're looking for or something else.

  • Start the virtual machine and wait for WF, does not connect to the computer virtual for Vds (Windows 2008 R2)

    Hello

    See a strange problem with only a Windows 2008 R2 model. When you use the built-in function "Start VM and wait" workflow to start a virtual machine (after conversion from a template either manually, or through workflow) NIC of the virtual machine (I tried VMXNET3 and e1000 times) does not connect to the problem. Vds can be replicated in a different VCenter, so spreading the vds. I also created several models of Windows 2008 r2 and all have this problem.

    If the model is converted and started outside VRO, it gets an IP from and is connected to the VDS immediately

    Tried add/remove the NIC of the model

    Tried to move the comments on different hosts

    Tried to create a new template from scratch

    NOTE: Windows 2012 R2 doesn't have this problem in the same circles, the only constant is the Windows 2008 R2 being started by VRO.

    Anyone seen this before?

    I found this article and it fixed my problem VMware KB: registration or the deployment of a virtual computer model fails apparently a fix a problem in ESX 5.1, 5.5 (I used the option to get around and things are good)

  • Dedicated network adapter to the virtual machine and the host computer not let can visit his profile

    OK, here's my question, I know how to give themselves a phyiscal nic to a vmware, but I wanted to take it one step further and do not leave the host send or receive data from this network card, only the virtual machine can use this network/NIC...

    Here's my reasoning, I have to network conections, one is for my internal/field network and the second is a direct connection to the internet (Comcast) I don't want to use to separate the machines have for internet connection, I want to be on the same machine phyiscal and have just the vmware machine talking to comcast... is it possible?  I am running VMware workstation 7, last update.

    Thank you

    Cdrshm

    I assume you are using a Windows host?

    If Yes...

    -first set up networking networking with vmnetcfg.exe

    -assign vmnet0 to the network card for the internal network

    -assign vmnet2 to the network card used for direct access to the internet

    -Right-click on the map network-icon in the systray and access the properties of the network adapter for vmnet2

    -Disable all other protocols and the Protocol of vmware_bridge for this network adapter

    result: a virtual machine that uses vmnet2 can directly access the internet and the host has no IP address for this network adapter - and therefore cannot use it.

    _________________________

    VMX-settings- WS FAQ -[MOAcd | http://sanbarrow.com/moa241.html]- VMDK-manual

  • PowerCLI Script to change the DNS servers and domain name

    Hello

    Brand new to PowerCLI, I'm trying to create a script that will change the domain name and the DNS servers of my ESXi servers. I found that I need to update the Vmware.Vim.HostDnsConfig to update these settings. I created the following script and the following error.

    $config = new-Object VMware.Vim.HostDnsConfig
    $config.domainName = "new.domain.com".
    $config.address = new-Object System.String [] (2)
    $config.address [0] = "10.69.69.80".
    $config.address [1] = "10.69.70.80".

    _this $ = get-view-Id "HostNetworkSystem-networkSystem.

    _this $. UpdateDnsConfig ($config)

    You can not call a method on a null value expression.

    Line: 1 char: 23

    + $_C. UpdateDnsConfig < < < < ($config)

    + CategoryInfo: InvalidOperation: (UpdateDnsConfig:String)], RuntimeException

    + FullyQualifiedErrorId: InvokeMethodOnNull

    I guessed the error message that I need to a value in the host name, I do not need to change the host name. So I create a variable to remove the host name and place it in the $config. Line received host name but still a mistake because the variable is pulling more information that I need.

    $hostname = get-VMHost | Select name

    $config. Hostname = $hostname

    When I insert the above code I have an error.

    Exception by calling 'UpdateDnsConfig' with '1' or the arguments: ' year error occurred during the configuration of the host.
    Line: 1 char: 23
    + $_C. UpdateDnsConfig < < < < ($config)
    + CategoryInfo: NotSpecified: (:)) [], MethodInvocationException)
    + FullyQualifiedErrorId: DotNetMethodException

    When I look at the $config I see the following.

    DHCP: false
    VirtualNicDevice:
    HostName: @{Name = ESXI01}
    Domain name: new.domain.com
    Address: {10.69.69.80, 10.69.70.80}
    SearchDomain:
    DynamicType:
    DynamicProperty:

    Of course the @{Name = ESXI01} will not work. Someone can explain how to get a host name in a variable and pass it to the Config.Hostname?

    You should be able to do easily by using the command "set-vmhostnetwork.

    I don't think that you can just write to VMWare.Vim.HostDnsConfig.

  • PS the script to display the virtual machines that reside on a specified vSwitch

    In the process of migration of virtual machines to vSphere 5 Cisco Nexus 1000v running.  However, I need to generate a list of VMS still residing on the old vSwitch in a datacenter.

    I know the powerpack VMware display the VMCount, but it would be useful to be able to run the script every morning and send the list of virtual machines residing on the old vSwitch automatically.

    VCenter 5 running.

    You have probably more than 1 portgroup with this name

    Try it like this

    ## name of portgroup whose VMs to get info on $strPortgroupName = "MyPortgroupName"
    ## Get the View object of the Network of the given name, then get the View objects of the VMs on that network, and return the VMs' names Get-View -Id (Get-View -ViewType Network -Property Name,VM -Filter @{"Name" = $strPortgroupName} | %{$_.VM}) -Property Name | select Name
    
  • How to change the virtual machine after clone

    I'm a beginner to learn vm.

    Now, I already cloned a new existing virtual machine in a virtual machine.

    Then, I want to change it.

    (1) change the name

    (2) change the number of the processor

    (3) change the size of the memory

    (4) change the size of the disk

    How to do?

    I use c# API. I put something when clone?

    Thanks for any help!

    Hello

    You can clone the virtual computer to a model first and then deploy it to this model. For customizing the properties of guest operating system, you can use sysprep (from Microsoft) or customization Spesification Manager (from VMware vCenter Server). Of course, you can also configure it manually change settings menu (from vSphere Client).

Maybe you are looking for

  • Sims 3 error loading (32415 = 00C &#62; DasmX86Dll.dll not found.) How can I fix it?

    This is what I get when I look for an error report in my folder sims 3, the game won't load after the loading screen, does anyone have a solution to this problem (my computer is well above all the required specifications of the system).              

  • Problems with Skype

    I try to connect with Skype and it tells me no how to fix this problem of reading one of your Blogs of connection are those with Maintenance problems and when it will be fixed

  • KB2538242 has successfully installed approximately 15 times

    I need help stopping this facility and get other updates... It's the ONLY update windows update installs... Someone help me please

  • How to activate the mode 'sleep'?

    I have windows Vista and when I was watching a movie online my screen became completely mode 'sleep'. I tried what in fact wake up but it does nothing, so whenever I want to use my computer that I need to use safe mode. How to turn off the mode stand

  • error code 19, Dr. rom.

    Hello After updating to service pack 2 (vista), I was not able to use my cd rom. I have tried all the suggestions on the forum but no luck. Windows looks for drivers but couldn't find. Then, I went to dell and found the drivers but I am unable to ins