Add .vmx files for inventory

Hi all

We have a situation where we try to automate the contribution of virtual machines on our site of DR. Right now we simulate this by using a separate VMFS data store. We use a SAN NetApp reflecting a copy of this course for the DR Datacentre, remove us the mirror, and then mount the VMFS datastore. But what we find is that in the data store, the file needs to be renamed before that we can add vmx to the other site, maybe it's because it still exists in the environment "under tension"? I'm not sure.

So, what I want to achieve is to have a script that I can specify the data store, cluster and perhaps the resource group, and he gets all the vmx files into this data store. I've seen an excellent script by LucD (attached) which looks perfect but when I run it it does not seem to do anything, but produces also no errors, I think it has something to do with the way in which it is to find the location of the data store, but I'm not sure about this at all.

I hope that makes sense.

##############################
# These settings

$dsname = "HS1-DRS-SYS1.
$datacenter = "mycompany".
$cluster = "Leeds".
$virtualcenterserver = "hs1-vmc-001.


#####################################################################################################
#Actual script (do not do any changes below this line

SE connect-VIServer-Server $virtualcenterserver
$ESXname = get-Cluster $cluster | Get-VMHost | Select - 1 first
$dsBrowser = get-View (Get-View (Get-VMHost-name $ESXname) USER.USER). DatastoreBrowser
$folder = get-View (Get-data center-name $datacenter |) Get - Folder - name "vm") USER.USER
$pool = get-View (Get-Cluster-name $cluster |) Get - ResourcePool - name 'Resources') USER.USER
#cls
Write-Host ""
Write-Host "Welcome to the Recovery System data store"
Write-Host ""
Write-Host "this script will now begin adding all THE VMs.
Write-Host "of the data store" $dsname "on vSphere Server" $virtualcenterserver
Write-Host ""
{foreach ($dsImpl to $dsBrowser.Datastore)}
$ds = get-views $dsImpl
if($DS.) Summary.Name - not $dsname) {continue}

$datastorepath = '[' + $ds. Summary.Name + '] '.

$searchspec = new-Object VMware.Vim.HostDatastoreBrowserSearchSpec
$searchSpec.matchpattern = '*.vmx.

Write-Host 'search in the path' $datastorepath

$task = get-view ($dsBrowser.SearchDatastoreSubFolders_Task ($datastorePath, $searchSpec))
While ($task.Info.State - eq 'running' - or $task.Info.State - eq 'pending') {}
$task. UpdateViewData()
sleep 5
}
If ($task.info.result - not $null) {}
{foreach ($file in $task.info.Result)}

if($file.) FolderPath - match ".snapshot") {continue}
$found = $FALSE
{foreach ($vmx to $vms)
If (($file.)) FolderPath + $file. File [0]. (Path) - eq $vmx) {}
Write-Host "" tVM is registered. "
$found = $TRUE
}
}
If (- not $found - and $task.Info.Result [0].) File - don't $null) {}
$vmx = $file. FolderPath + $file. File [0]. Path
$params = @($null, $FALSE, $vmx, $pool.) MoRef, $null)
Write-Host "Inscription" $vmx
$folder. GetType(). GetMethod ("RegisterVM_Task"). Invoke ($folder, $params)
}

}
}
}

When I run the present to the point where it says 'Welcome in the store of data recovery system' etc. and then nothing comes. I noticed a thread where I got it (thanks again) and it is mentioned and the NFS datastore that we use not, I guess we use the traditional method.

Furthermore, we use vSphere 4.0.

I tried to drop the script to understand what it is myself, but nothing works unfortunately and I am now Powershell guru! I noticed that if I run across it caraa the $datastorepath return [].

Any help with this would be much appreciated.

Thanks in adavnce

Julian

OK, let's check if the DatastoreBrowser is all warehouses data on all nodes.

This allows to check.

foreach($esx in Get-Cluster $cluster | Get-VMHost){
    $dsBrowser = Get-View $ESX.ExtensionData.DatastoreBrowser
    foreach($dsObj in $dsBrowser.Datastore){
        $ds = Get-View $dsObj        Write-Host $esx.Name $ds.Name
    }
}

Tags: VMware

Similar Questions

  • How can I add audio files for my adobe muse Web site?

    I'll be weekly by adding audio files to my muse site created and I wanted to know how to do. Any help would be greatly appreciated. Thank you!

    Bob

    You must add the files for download on your site of Muse, the option of the file menu.

    After you have added files, you can link the files with any text or page content. You can use the same method to load audio files every week.

    Thank you

    Sanjit

  • Location of the VMX file for a virtual machine

    My problem,

    I have a bunch of VM that names the real record of the VM and files below are NOT the same as the VM name shown at the VI appointed client. -J' it can't wait... makes more complicated

    I want to know is if there is a way to a virtual machine that is in inventory and get the path to his report and the real VMX path of query file, which I guess would give me the name of the data store and the record in the data store.

    My question for example:

    My - vma: (in VIclient)

    [myds0100]/web34/web34.vmx (because if I get off by accessing the site after clicking on 'my - vma' VM in viclient)]

    You can do

    Get - VM | Select the path Name,@{N="VMX"; E={$_. ExtensionData.Config.Files.VmPathName}}

    You could also have a look at the VIProperty called VmxDatastoreFullPath.

  • Need to remove the advanced values in VMX file

    Former Director elected to harden all VMs VMX files in order to avoid interruptions in service unwanted individuals manual installation of the VMware tools upgrades.

    I agree with him and understand in previous versions, it was a good idea to disable these but now with 5.1 with the fact that we have more to restart for the modernization of the tools happen my life has become much more complicated and we constantly have problems with VM with mounted tools and no way forced to disassemble the tools.

    I am looking for PowerCLI script to remove these advanced values in the VMX file for all the virtual machines attached to a vCenter. I guess these are the following values:

    isolation.tools.autoInstall.disable = true

    isolation.tools.guestInitiatedUpgrade.disable = false

    insulation. Tools.connectable.Disable =true

    If there are other values that I should check, please let me know and I will review the VMX file.

    This is another option, but lines will remain in the VMX, albeit with different values

    You can do it with this script

    $vm = Get-VM -Name MyVM
    
    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec$spec.tools = New-Object VMware.Vim.ToolsConfigInfo
    
    $extra1 = New-Object VMware.Vim.OptionValue$extra1.Key = "isolation.tools.autoInstall.disable"$extra1.Value = "false"$spec.ExtraConfig += $extra1$extra2 = New-Object VMware.Vim.OptionValue$extra2.Key = "isolation.tools.guestInitiatedUpgrade.disable"$extra2.Value = "true"$spec.ExtraConfig += $extra2$extra3 = New-Object VMware.Vim.OptionValue$extra3.Key = "isolation.tools.connectable.disable"$extra3.Value = "flase"$spec.ExtraConfig += $extra3
    
    $vm.ExtensionData.ReconfigVM($spec)
    
  • Using several data stores, cannot migrate the vmx file in a data store

    I am host migration between 3.5 and 4.0, and part of the migration requires me to vmotion data to a single shared LUN data warehouses.  From there on, I import the virtual machine in 4.0 and using the script to migrate the two VM disks at different stores of data below.  The problem I have is that the configuration (vmx) file not migrated and is left on the shared storage LUNS.  Anyone knows how to go beyond this?

    The Script:

    $VMDisk = 'disk 1 '.

    $VMName = 'TestVM '.

    $TargetDS = get-Datastore - VMHost (Get-VMHost-$S.id Id) | Where-Object {$_.} Name - like "PMV"} | "" FreeSpaceMB tri-objet-descending | SELECT name - first of all 1

    $vm = get-View - ViewType VirtualMachine-filter @{"Name" = $VMName}

    foreach ($dev in $vm. Config.Hardware.Device) {if ($dev. DeviceInfo.Label - eq $vmDisk) {$diskId = $dev. Key}}

    $spec = new-Object VMware.Vim.VirtualMachineRelocateSpec

    $diskspec = new-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator

    $diskspec. Data store = (Get-Datastore-name $TargetDS.Name |) Get - View). MoRef

    $diskspec.diskId = $diskId

    $spec. Disk = @($diskspec)

    $task = get-View ($vm. RelocateVM_Task ($spec, "lowpriority"))

    OK, I think I understand your problem now.

    I fear that in the current construction of PowerCLI, the Move-VM cmdlet does not destinations of individual data for each virtual hard disk store.

    With the RelocateVM_Task method, it is possible.

    The following script moves a guest at 3 different data warehouses:

    -the. VMX file for DS2

    -hard disk 1 for DS3

    -hard drive 2 TB DS4

    $vmName = "MyGuest"
    $vmxDS = "DS2"
    $osDS = "DS3"
    $dataDS = "DS4"
    
    $vm = Get-VM -Name $vmName
    
    $vm.Extensiondata.Config.Hardware.Device | %{
         if ($_.DeviceInfo.Label -eq "Hard disk 1"){
              $osDiskId = $_.Key
         }
         elseif($_.DeviceInfo.Label -eq "Hard disk 2"){
              $dataDiskId = $_.Key
         }
    }
    
    $spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
    
    $osRelocate = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator
    $osRelocate.Datastore = (Get-Datastore -Name $osDS).Extensiondata.MoRef
    $osRelocate.diskId = $osDiskId
    
    $dataRelocate = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator
    $dataRelocate.Datastore = (Get-Datastore -Name $dataDS).Extensiondata.MoRef
    $dataRelocate.diskId = $dataDiskId
    
    $spec.Disk = @($osRelocate,$dataRelocate)
    $spec.Datastore = (Get-Datastore -Name $vmxDS).Extensiondata.MoRef
    $spec.Host = $vm.Extensiondata.Summary.Runtime.Host
    
    $task = Get-View ($vm.Extensiondata.RelocateVM_Task($spec, "lowpriority"))
    while("running","queued" -contains $task.Info.State){
         $task.UpdateViewData("Info")
         sleep 5
    }
    

    BTW, you can use the cmdlet Set - hard disk to a virtual disk that is specific to a data store.

    But as I understood what is not possible in your environment.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Add VM for inventory does not

    Hello

    I try to use PowerCLI to add a virtual machine to inventory.  I know the exact location and I am not having any questions see the file, I even checked the location using ls:

    LS vmstores:\srmvc2. MYDOMAIN.ca@443\DR\NASG_SVM1_ESX_Templates\PICOB_NEW1\PICOB_NEW1.vmx

    The data store path: [NASG_SVM1_ESX_Templates] PICOB_NEW1

    LastWriteTime length name Type
    -------------            ----       ------ ----
    2016/04/18 11:35 VmConfigFile 3554 PICOB_NEW1.vmx

    This result seems to indicate that the vmx file path is correct, I try to add the file to the inventory using the following command:

    New-VM - VMHost srmesxi62. MYDOMAIN.ca - location migration - VMFilePath 'vmstores:\srmvc2. MYDOMAIN.ca@443\DR\NASG_SVM1_ESX_Templates\PICOB_NEW1\PICOB_NEW1.vmx ".

    This property returns an invalid path error.  This should be simple to fix, but I do not see where I am going wrong.  Any ideas?

    Your formatting of path is incorrect, try this:

    New-VM -VMHost srmesxi62.MYDOMAIN.ca -Location Migrating -VMFilePath "[NASG_SVM1_ESX_Templates] PICOB_NEW1/PICOB_NEW1.vmx"
    
  • You try to play the file vmx, looking for a certain value

    We had a third-party deployment go wrong.  They add a few lines in vmx files and these lines are originally NIC disconnect and reconnect not.  We have almost 500 VMS and so I try to make a loop on all virtual machines looking for a value.

    I've been playing with Get-AdvancedSetting and I can get the values I'm looking for, but I can't get the name of VM affected to appear as well.

    For example:

    Get-AdvancedSetting - entity (Get - vm) - name ethernet0.filter0.name

    Name value Type Description
    ----                 -----                ----                 -----------
    ethernet0.filter0... vtap_vmkern VM
    ethernet0.filter0... vtap_vmkern VM
    ethernet0.filter0... vtap_vmkern VM
    ethernet0.filter0... vtap_vmkern VM
    ethernet0.filter0... vtap_vmkern VM

    It returns only the name and the value of the AdvancedSetting, I can't understand how to include the name of the server.

    Finally, I have to write a script to remove the affected rows, but for now, I just want to get a list of the virtual machines that have these lines.

    You could do something like that

    {foreach ($vm in Get - VM)

    Get-AdvancedSetting - $vm - name ethernet0.filter0.name entity.

    Select @{N = "VM"; E = {$vm. Name}}, name, value, type

    }

  • Press on getting my vSphere and vCentre to display the vmdk file for my vmx file

    Hello, I was wondering if you could help me.

    I got some virtual machines also in my company to implement for a demonstration we will have soon. We currently have a demo system implemented with vSphere and vCentre 4.0.0 uses. We have been given the files have been imported into the data store vCentre via vSphere interface (see Datastore.bmp)
    I added the virtual machine on my inventory, but when I try to turn it on I get the following error messages (see Error.bmp and bottombar_error.bmp)
    How can I get the vmx file (which I'm trying to power on) to show the vmdk (hard drive) file?
    I looked in the edit settings section and made sure that it points in the right direction and I am all of these ideas.
    Concerning
    KatieV

    Welcome to the communities.

    I found follow Ko, may help you http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1005628

    GL

  • LabVIEW allows to read an Excel file to a control and add a checkbox for each line

    As say the topic, I need to use labview to read an excel file and show it in a control, such as mclb; I should add a checkbox for each line then allow me to choose the line I want. What should I do? Thank you very much.

    guiming wrote:

    I can read an Excel file to a spreadsheet, but I have no idea how to do to add a checkbox for each line.

    Sometimes, all you need to do is Google. https://decibel.NI.com/content/docs/doc-25000

    http://www.labviewing.com/check-box-in-multicolumn-ListBox/

  • Add a vmx file entry

    If I add an entry in a file such as Get - VM's vmx | New-AdvancedSetting - name "isolation.tools.diskShrink.disable" - value $true.

    This will require a reboot of the virtual machine to take effect?

    http://www.virtuallyghetto.com/2014/03/a-kitten-is-also-harmed-every-time-you-edit-a-vmx-file-by-hand.html is a good read

    William has an interesting workaround solution using vMotion to cause the changes take effect without needing a reboot (have a read of the last paragraph)

  • script to check a setting in a file for specific entry vmx

    HI friends,

    I wonder if it is possible to control the specific entry VMX file via script powercli. Actually I wanted to search for all virtual machines which has "scsi0:1.writeThrough ="true"in the VMX file. You guys can help me please.

    Of course, try something like this

    $vmName = "VM*"$tgtFolder = "C:\Temp\VMX\"$tgtString = 'scsi0:1.writeThrough = "true"'
    
    Get-VM -Name $vmName | %{  $dsName,$vmxPath = $_.ExtensionData.Config.Files.VmPathName.Split()  $dsName = $dsName.Trim('[]')  $ds = Get-Datastore -Name $dsName  New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root "\" | Out-Null  Copy-DatastoreItem -Item "DS:$vmxPath" -Destination $tgtFolder  Remove-PSDrive -Name DS -Confirm:$false}
    
    Get-ChildItem -Path $tgtFolder -Filter "*.vmx" | Where {Get-Content -Path $_.FullName | Select-String -Pattern $tgtString} |Select Name
    

    It displays the name of each VMX file in which the string "scsi0:1.writeThrough =" True "" is located.

  • Is this really the case with the free player, the clients can access is no longer a PDF to add comments and mark out? We have always used a PDF file for the reviews of books/documents, but now we hear customers that there is no way to add comments and ann

    Is this really the case with the free player, the clients can access is no longer a PDF to add comments and mark out? We have always used a PDF file for the reviews of books/documents, but now we hear customers that there is no way to add comments and annotation. Please let me know if this is the case, or if there is a solution

    '' If '' they use the free software Adobe Reader and "If" there is no security prevent this, he should be able to add comments.

    It'll be hard to say what's wrong without more details such as what exact version of the reader they use, they open the pdf file in a browser or in the player itself and what exactly happens when they try to add comments.

  • How can I add the Raw for the Canon EOS Rebel T6s file 5 Lightroom

    You want to know if there is a way to add the RAW file for the new Canon EOS Rebel T6s format to my desktop Mac version 5 of Lightroom.  All I found was the plugin cameraRaw 9 for Lightroom 6 that takes in charge of my camera. This does not work after that I have download and run the installation

    Thank you

    You will need to convert RAW to DNG for use in LR 5. Or you can go to LR 6. CameraRaw plugin is not relevant to LR. This is for Photoshop.

  • Having problem to add code to the .vmx file.

    I try to add the code below in my .vmx file.

    mainMem.useNamedFile = "FALSE".
    MemTrimRate = 0
    prefvmx.minVmMemPct = "100".
    prefvmx.useRecommendedLockedMemSize = 'TRUE '.
    sched.mem.pshare.Enable = "FALSE".
    I added my vmx file attachments, so you can take a look.
    I added these lines of code to the wrong file?

    After that, I am unable to open the virtual machine and get an error message:

    http://i50.Tinypic.com/33mwub9.PNG

    IM using Windows 7 pro on the host computer. With the help of VMware Workstation 8

    Help please! =)

    The file you connected, Windows 7 vmxf, isn't the .vmx config file and does not have the file, you should be editing!   Remove your Windows 7 vmxf file changes and edit the .vmx instead.  If you still have questions after that cleaning of the .vmxf file and modifying the .vmx file and then archive them both in a zip file and attach to a response message.

  • Can I add new tokens for the HTML template file?

    In the "index.template.html" HTML template file, there are chips form ${swf} which get a substitution of string value when "index.html" is generated.

    I would like to add a few new tokens like 'configurationFile' and determine the value of string elsewhere in the project.  The properties of the project would be very nice.

    Can I do this?  Or do I have to add my own Ant build file for this operation?

    Oz

    4Dtext tools

    Right now, the list of the tokens is hard-coded in Flash Builder. But this looks like an interesting enhancement request.

    Would be nice to have it filed at https://bugs.adobe.com/flex.

    -Remy

Maybe you are looking for

  • dual GigE card

    I need to use 2 cameras gigE on a system and am looking for a dual port card, is there a favorite one to work with windows 7 and imaqDX drivers to connect with 2 gige cameras.

  • How can I reset my computer to factory settings

    original title: factory settings How can I reset my desktop to factory settings trying to avoid having to reformat my computer crashes, freeze and are very slow, I tried f10 at startup, do nothing please help :)

  • HP LaserJet P1102W: HP LaserJet P1102w prints 1/2 inch too far down on the page

    When I print with that printer using Word, it starts about a half inch of print down on the page. I tried to reset to factory settings, but it does not always work on me. Any help would be appreciated.

  • Send sms - timeout

    Hi all I have a simple code to send sms. It works very well. Just a glitch. How will I know that sms cannot be sent? Some timeout for the connection or otherwise? Let's say that if there is no network, no sim card or any credit. Thank you Here is the

  • Recently, I was unable to boot my laptop HP Pavilion

    I was running Windows 7 Home, 64-bit, SP1.  I had just solved other problems after many hours.  Those who required to uninstall then reinstall all 3 browsers.  When I finished that I violated one of my cardinal rules.  I downloaded, installed and run