1 2 Previous Next 23 Replies Latest reply on May 24, 2019 2:14 PM by LucD

    Scripting batch import of VM's using vmx

    vJoeG Hot Shot
    VMware Employees

      Good afternoon all,

       

      We've been scripting the migration of VM's from an older 5.5 vCenter to 6.5 vCenter

       

      Using PowerShell we've created a way to copy all of the folders into the new Datastore and want to automate the import as well.

       

      Cannot use the Migration fling as our source environment is 5.5 and the fling requires 6.0u3 vCenter

       

      The command in question is

       

      new-vm -VMFilePath "[Datastore] MigrationVMs/EDE-900##/EDE-900##.vmx" -VMHost ourhost1.domain.com -Location MigratedVMs

       

      When this is run from script or command line the error is:

       

      "new-vm : 5/23/2019 1:45:16 PM    New-VM    The operation for the entity "MigratedVMs" failed with the following message: "A specified parameter was not correct: path"

       

      This blog was where I took the code sample.

       

      http://www.wooditwork.com/2011/08/11/adding-vmx-files-to-vcenter-inventory-with-powercli-gets-even-easier/

       

      Thanks in advance

        • 1. Re: Scripting batch import of VM's using vmx
          LucD Guru
          Community WarriorsUser ModeratorsvExpert

          Did you already try with

           

          New-VM -VMFilePath "[Datastore] MigrationVMs/EDE-900##/EDE-900##.vmx" -VMHost ourhost1.domain.com -Location (Get-Folder -Name MigratedVMs)

           

          • 2. Re: Scripting batch import of VM's using vmx
            vJoeG Hot Shot
            VMware Employees

            Luc

             

            I have not but I will give it a try. Thanks for the suggestion.

            • 3. Re: Scripting batch import of VM's using vmx
              vJoeG Hot Shot
              VMware Employees

              Confirmed that Get-Folder -name MigratedVMs looks good

               

              2019-05-23_15-58-54.png

               

              adding it to the full command produces the same error.

              • 4. Re: Scripting batch import of VM's using vmx
                LucD Guru
                vExpertUser ModeratorsCommunity Warriors

                Which PowerCLI version are you using?

                If not on 11.2.0, can you upgrade?

                • 5. Re: Scripting batch import of VM's using vmx
                  vJoeG Hot Shot
                  VMware Employees

                  Checked and confirmed 11.2

                   

                  Powercli-11-2.png

                  • 6. Re: Scripting batch import of VM's using vmx
                    LucD Guru
                    User ModeratorsCommunity WarriorsvExpert

                    Next step would be to have a look at the vpxd log.
                    Any hints in there at the time you run the New-VM?

                    • 7. Re: Scripting batch import of VM's using vmx
                      vJoeG Hot Shot
                      VMware Employees

                      Have to admit the logs still read like a foreign language to me:

                       

                      Here's what I think I found

                      2019-05-23T18:45:13.405Z error vpxd[7F8B075EB700] [Originator@6876 sub=VmProv opID=627f3502-01] [VpxdVmprovUtil] Unable to register Vm ds:///vmfs/volumes/vsan:523878c4da4c52b1-7b8bfe26b8febe58/MigrationVMs/EDE-90010/EDE-90010.vmx

                      2019-05-23T18:45:13.407Z error vpxd[7F8B075EB700] [Originator@6876 sub=VmProv opID=627f3502-01] Get exception while executing action vpx.vmprov.RegisterDestinationVm: N5Vmomi5Fault15InvalidArgument9ExceptionE(vmodl.fault.InvalidArgument)

                      --> [context]zKq7AVECAAAAAOEb0AAfdnB4ZAAATHorbGlidm1hY29yZS5zbwAAHiQbAD5yGAFqPhlsaWJ2bW9taS5zbwABfEQZAiphdHZweGQAAp5kdAJSZMsCHzrQAuWj0QIQ2c4ClvvOAuMAzwJT6HMCyN1zAn8CdALeynMCYYbKAleHygIC83iDBl8GAWxpYnZpbS10eXBlcy5zbwACOvF0AlPocwLI3XMCfwJ0AsBVdAALxSMA8scjAAPTKwTUcwBsaWJwdGhyZWFkLnNvLjAABb2ODmxpYmMuc28uNgA=[/context]

                      2019-05-23T18:45:13.409Z info vpxd[7F8B075EB700] [Originator@6876 sub=VmProv opID=627f3502-01] Workflow context:

                      --> (vpx.vmprov.RegisterContext) {

                      -->    cbData = <unset>,

                      -->    prevOutput = <unset>,

                      -->    vmName = <unset>,

                      -->    vmPathName = "ds:///vmfs/volumes/vsan:523878c4da4c52b1-7b8bfe26b8febe58/MigrationVMs/EDE-90010/EDE-90010.vmx",

                      -->    dstLocation = (vpx.vmprov.VmLocation) {

                      -->       service = (vpx.vmprov.ServiceEndpointState) {

                      -->          instanceName = "LUJ1VDIVC01.UTILITIES.LOCAL",

                      -->          url = "https://LUJ1VDIVC01.UTILITIES.LOCAL:443/sdk",

                      -->          about = (vim.AboutInfo) {

                      -->             name = "VMware VirtualCenter",

                      -->             fullName = "VMware VirtualCenter Server",

                      -->             vendor = "",

                      -->             version = "6.5.0",

                      -->             build = "13638625",

                      -->             localeVersion = <unset>,

                      -->             localeBuild = <unset>,

                      -->             osType = "linux-x64",

                      -->             productLineId = "vpx",

                      -->             apiType = "VirtualCenter",

                      -->             apiVersion = "6.5",

                      -->             instanceUuid = "ccd5d016-f4f1-402a-86fc-11addee541c9",

                      -->             licenseProductName = "VMware VirtualCenter Server",

                      -->             licenseProductVersion = "6.0"

                      -->          }

                      -->       },

                      -->       datacenter = 'vim.Datacenter:ccd5d016-f4f1-402a-86fc-11addee541c9:datacenter-21',

                      -->       folder = 'vim.Folder:ccd5d016-f4f1-402a-86fc-11addee541c9:group-v141',

                      -->       computeResource = 'vim.ClusterComputeResource:ccd5d016-f4f1-402a-86fc-11addee541c9:domain-c26',

                      -->       pool = 'vim.ResourcePool:resgroup-27',

                      -->       host = (vpx.vmprov.HostState) {

                      -->          host = 'vim.HostSystem:ccd5d016-f4f1-402a-86fc-11addee541c9:host-29',

                      -->          product = (vim.AboutInfo) {

                      -->             name = "VMware ESXi",

                      -->             fullName = "VMware ESXi 6.5.0 build-10884925",

                      -->             vendor = "VMware, Inc.",

                      -->             version = "6.5.0",

                      -->             build = "10884925",

                      -->             localeVersion = "INTL",

                      -->             localeBuild = "000",

                      -->             osType = "vmnix-x86",

                      -->             productLineId = "embeddedEsx",

                      -->             apiType = "HostAgent",

                      -->             apiVersion = "6.5",

                      -->             instanceUuid = <unset>,

                      -->             licenseProductName = "VMware ESX Server",

                      -->             licenseProductVersion = "6.0"

                      -->          },

                      -->          uuid = "4c4c4544-0057-5a10-804c-cac04f4d5232",

                      -->          managementIp = "10.69.8.51",

                      -->          cnxSpec = (nfc.CopySpec.CnxSpec) {

                      -->             host = "10.69.8.51",

                      -->             port = 902,

                      -->             authData = (nfc.CopySpec.UsernamePasswd) {

                      -->                username = "vpxuser",

                      -->                password = (not shown),

                      -->                sslThumbprint = "77:55:3E:8B:2F:D3:46:D2:14:59:AA:EB:F9:97:EA:4B:47:0D:FB:F0"

                      -->             },

                      -->             useSSL = true

                      -->          },

                      -->          sslThumbprint = "77:55:3E:8B:2F:D3:46:D2:14:59:AA:EB:F9:97:EA:4B:47:0D:FB:F0",

                      -->          capability = (vim.host.Capability) {

                      -->             recursiveResourcePoolsSupported = true,

                      -->             cpuMemoryResourceConfigurationSupported = true,

                      -->             rebootSupported = true,

                      -->             shutdownSupported = true,

                      -->             vmotionSupported = true,

                      -->             standbySupported = true,

                      -->             ipmiSupported = true,

                      -->             maxSupportedVMs = <unset>,

                      -->             maxRunningVMs = 0,

                      -->             maxSupportedVcpus = <unset>,

                      -->             maxRegisteredVMs = 4096,

                      -->             datastorePrincipalSupported = false,

                      -->             sanSupported = true,

                      -->             nfsSupported = true,

                      -->             iscsiSupported = true,

                      -->             vlanTaggingSupported = true,

                      -->             nicTeamingSupported = true,

                      -->             highGuestMemSupported = true,

                      -->             maintenanceModeSupported = true,

                      -->             suspendedRelocateSupported = true,

                      -->             restrictedSnapshotRelocateSupported = true,

                      -->             perVmSwapFiles = true,

                      -->             localSwapDatastoreSupported = true,

                      -->             unsharedSwapVMotionSupported = true,

                      -->             backgroundSnapshotsSupported = false,

                      -->             preAssignedPCIUnitNumbersSupported = true,

                      -->             screenshotSupported = true,

                      -->             scaledScreenshotSupported = true,

                      -->             storageVMotionSupported = true,

                      -->             vmotionWithStorageVMotionSupported = true,

                      -->             vmotionAcrossNetworkSupported = true,

                      -->             maxNumDisksSVMotion = 248,

                      -->             hbrNicSelectionSupported = true,

                      -->             vrNfcNicSelectionSupported = true,

                      -->             recordReplaySupported = false,

                      -->             ftSupported = false,

                      -->             replayUnsupportedReason = "incompatibleCpu",

                      -->             replayCompatibilityIssues = <unset>,

                      -->             checkpointFtSupported = false,

                      -->             smpFtSupported = false,

                      -->             ftCompatibilityIssues = (string) [

                      -->                "incompatibleCpu",

                      -->                "missingFTLoggingNic"

                      -->             ],

                      -->             checkpointFtCompatibilityIssues = <unset>,

                      -->             smpFtCompatibilityIssues = (string) [

                      -->                "missingFTLoggingNic"

                      -->             ],

                      -->             maxVcpusPerFtVm = 4,

                      -->             loginBySSLThumbprintSupported = true,

                      -->             cloneFromSnapshotSupported = true,

                      -->             deltaDiskBackingsSupported = true,

                      -->             perVMNetworkTrafficShapingSupported = false,

                      -->             tpmSupported = true,

                      -->             supportedCpuFeature = <unset>,

                      -->             virtualExecUsageSupported = true,

                      -->             storageIORMSupported = true,

                      -->             vmDirectPathGen2Supported = true,

                      -->             vmDirectPathGen2UnsupportedReason = <unset>,

                      -->             vmDirectPathGen2UnsupportedReasonExtended = <unset>,

                      -->             supportedVmfsMajorVersion = (int) [

                      -->                5,

                      -->                6

                      -->             ],

                      -->             vStorageCapable = true,

                      -->             snapshotRelayoutSupported = true,

                      -->             firewallIpRulesSupported = true,

                      -->             servicePackageInfoSupported = true,

                      -->             maxHostRunningVms = 1024,

                      -->             maxHostSupportedVcpus = 1280,

                      -->             vmfsDatastoreMountCapable = true,

                      -->             eightPlusHostVmfsSharedAccessSupported = true,

                      -->             nestedHVSupported = true,

                      -->             vPMCSupported = true,

                      -->             interVMCommunicationThroughVMCISupported = false,

                      -->             scheduledHardwareUpgradeSupported = true,

                      -->             featureCapabilitiesSupported = true,

                      -->             latencySensitivitySupported = true,

                      -->             storagePolicySupported = true,

                      -->             accel3dSupported = false,

                      -->             reliableMemoryAware = true,

                      -->             multipleNetworkStackInstanceSupported = true,

                      -->             messageBusProxySupported = true,

                      -->             vsanSupported = true,

                      -->             vFlashSupported = true,

                      -->             hostAccessManagerSupported = true,

                      -->             provisioningNicSelectionSupported = true,

                      -->             nfs41Supported = true,

                      -->             nfs41Krb5iSupported = true,

                      -->             turnDiskLocatorLedSupported = true,

                      -->             virtualVolumeDatastoreSupported = true,

                      -->             markAsSsdSupported = true,

                      -->             markAsLocalSupported = true,

                      -->             smartCardAuthenticationSupported = true,

                      -->             pMemSupported = <unset>,

                      -->             cryptoSupported = true,

                      -->             oneKVolumeAPIsSupported = true,

                      -->             gatewayOnNicSupported = true,

                      -->             upitSupported = <unset>,

                      -->             cpuHwMmuSupported = true,

                      -->             encryptedVMotionSupported = true,

                      -->             encryptionChangeOnAddRemoveSupported = false,

                      -->             encryptionHotOperationSupported = false,

                      -->             encryptionWithSnapshotsSupported = false,

                      -->             encryptionFaultToleranceSupported = false,

                      -->             encryptionMemorySaveSupported = false,

                      -->             encryptionRDMSupported = false,

                      -->             encryptionVFlashSupported = false,

                      -->             encryptionCBRCSupported = false,

                      -->             encryptionHBRSupported = false

                      -->          },

                      -->          internalCapability = (vim.host.InternalCapability) {

                      -->             enumerateExtentsSupported = true,

                      -->             fastSuspendResumeSupported = true,

                      -->             svmVmxDiskCopySupported = true,

                      -->             evcSoftwareSupported = true,

                      -->             compatibleEVCModeKeys = <unset>,

                      -->             lunDisplayNameSupported = true,

                      -->             virtualDiskDigestSupported = true,

                      -->             hostProfileEngineSupported = true,

                      -->             controllableStatsCountersSupported = true,

                      -->             nfcCopyRawDiskMappingSupported = true,

                      -->             nfcCopyDeltaDiskSupported = true,

                      -->             vmotionHostLogStateSupported = true,

                      -->             operationCleanupManagerSupported = true,

                      -->             operationCleanupManagerSupportedForCreate = true,

                      -->             queryMigrationIdsSupported = true

                      -->          },

                      -->          vmSwapPlacement = "vmDirectory",

                      -->          localSwapDatastore = (vpx.vmprov.DatastoreState) null,

                      -->          localSwapDatastoreWritable = <unset>,

                      -->          configOption = (vim.vm.ConfigOption) null,

                      -->          mountInfo = <unset>,

                      -->          vNicInfo = (vim.host.VirtualNicManagerInfo) null,

                      -->          network = (vim.host.NetworkInfo) null,

                      -->          optionDef = <unset>,

                      -->          provPolicy = (vim.vm.ProvisioningPolicy) null,

                      -->          vFlashModules = (vim.host.VFlashManager.VFlashCacheConfigInfo.VFlashModuleConfigOption) [

                      -->             (vim.host.VFlashManager.VFlashCacheConfigInfo.VFlashModuleConfigOption) {

                      -->                vFlashModule = "vfc",

                      -->                vFlashModuleVersion = "1.0.0.0",

                      -->                minSupportedModuleVersion = "1.0.0.0",

                      -->                cacheConsistencyType = (vim.option.ChoiceOption) {

                      -->                   valueIsReadonly = true,

                      -->                   choiceInfo = (vim.ElementDescription) [

                      -->                      (vim.ElementDescription) {

                      -->                         label = "strong",

                      -->                         summary = "Cache data consistency is guaranteed after a crash",

                      -->                         key = "strong"

                      -->                      }

                      -->                   ],

                      -->                   defaultIndex = 0

                      -->                },

                      -->                cacheMode = (vim.option.ChoiceOption) {

                      -->                   valueIsReadonly = true,

                      -->                   choiceInfo = (vim.ElementDescription) [

                      -->                      (vim.ElementDescription) {

                      -->                         label = "write_thru",

                      -->                         summary = "Writes to the cache cause writes to the underlying storage",

                      -->                         key = "write_thru"

                      -->                      }

                      -->                   ],

                      -->                   defaultIndex = 0

                      -->                },

                      -->                blockSizeInKBOption = (vim.option.LongOption) {

                      -->                   valueIsReadonly = <unset>,

                      -->                   min = 4,

                      -->                   max = 1024,

                      -->                   defaultValue = 8

                      -->                },

                      -->                reservationInMBOption = (vim.option.LongOption) {

                      -->                   valueIsReadonly = <unset>,

                      -->                   min = 4,

                      -->                   max = 409600,

                      -->                   defaultValue = 4

                      -->                },

                      -->                maxDiskSizeInKB = 17179869184

                      -->             }

                      -->          ],

                      -->          vFlashResourceAccessible = false

                      -->       },

                      -->       primaryDatastore = (vpx.vmprov.DatastoreState) {

                      -->          datastore = 'vim.Datastore:ccd5d016-f4f1-402a-86fc-11addee541c9:datastore-31',

                      -->          summary = (vim.Datastore.Summary) {

                      -->             datastore = 'vim.Datastore:ccd5d016-f4f1-402a-86fc-11addee541c9:datastore-31',

                      -->             name = "VxRail-Virtual-SAN-Datastore-ed02b471-52cf-4da2-88d2-db559109917e",

                      -->             url = "ds:///vmfs/volumes/vsan:523878c4da4c52b1-7b8bfe26b8febe58/",

                      -->             capacity = 138266825195520,

                      -->             freeSpace = 132600828002304,

                      -->             uncommitted = 1367700776040,

                      -->             accessible = true,

                      -->             multipleHostAccess = true,

                      -->             type = "vsan",

                      -->             maintenanceMode = "normal"

                      -->          },

                      -->          capability = (vim.Datastore.Capability) {

                      -->             directoryHierarchySupported = true,

                      -->             rawDiskMappingsSupported = true,

                      -->             perFileThinProvisioningSupported = true,

                      -->             storageIORMSupported = false,

                      -->             nativeSnapshotSupported = false,

                      -->             nativeSnapshotCopySupported = false,

                      -->             topLevelDirectoryCreateSupported = false,

                      -->             seSparseSupported = false,

                      -->             vmfsSparseSupported = false,

                      -->             vsanSparseSupported = true,

                      -->             upitSupported = <unset>,

                      -->             vmdkExpandSupported = <unset>

                      -->          }

                      -->       },

                      -->       datastore = (vpx.vmprov.DatastoreState) [

                      -->          (vpx.vmprov.DatastoreState) {

                      -->             datastore = 'vim.Datastore:ccd5d016-f4f1-402a-86fc-11addee541c9:datastore-31',

                      -->             summary = (vim.Datastore.Summary) {

                      -->                datastore = 'vim.Datastore:ccd5d016-f4f1-402a-86fc-11addee541c9:datastore-31',

                      -->                name = "VxRail-Virtual-SAN-Datastore-ed02b471-52cf-4da2-88d2-db559109917e",

                      -->                url = "ds:///vmfs/volumes/vsan:523878c4da4c52b1-7b8bfe26b8febe58/",

                      -->                capacity = 138266825195520,

                      -->                freeSpace = 132600828002304,

                      -->                uncommitted = 1367700776040,

                      -->                accessible = true,

                      -->                multipleHostAccess = true,

                      -->                type = "vsan",

                      -->                maintenanceMode = "normal"

                      -->             },

                      -->             capability = (vim.Datastore.Capability) {

                      -->                directoryHierarchySupported = true,

                      -->                rawDiskMappingsSupported = true,

                      -->                perFileThinProvisioningSupported = true,

                      -->                storageIORMSupported = false,

                      -->                nativeSnapshotSupported = false,

                      -->                nativeSnapshotCopySupported = false,

                      -->                topLevelDirectoryCreateSupported = false,

                      -->                seSparseSupported = false,

                      -->                vmfsSparseSupported = false,

                      -->                vsanSparseSupported = true,

                      -->                upitSupported = <unset>,

                      -->                vmdkExpandSupported = <unset>

                      -->             }

                      -->          }

                      -->       ]

                      -->    },

                      -->    isTemplate = false,

                      -->    dstVm = 'vim.VirtualMachine:ccd5d016-f4f1-402a-86fc-11addee541c9:vm-166'

                      --> }

                      2019-05-23T18:45:13.412Z info vpxd[7F8B075EB700] [Originator@6876 sub=VmProv opID=627f3502-01] Undo action vpx.vmprov.RegisterDestinationVm

                      • 8. Re: Scripting batch import of VM's using vmx
                        LucD Guru
                        vExpertUser ModeratorsCommunity Warriors

                        The InvalidArgument fault on the RegisterVM_Task method signals that "Thrown if any of the arguments such as host or resource pool are not set to valid values."

                        Can you try the New-VM with just the VmFilePath parameter?

                        • 9. Re: Scripting batch import of VM's using vmx
                          LucD Guru
                          Community WarriorsvExpertUser Moderators

                          Could it be that this VM was, at the time it was unregistered, in a ResourcePool that doesn't exist anymore?
                          You could try to specify a target ResourcePool explicitly on the New-VM cmdlet.

                          • 10. Re: Scripting batch import of VM's using vmx
                            vJoeG Hot Shot
                            VMware Employees

                            Running it without the -Location yields the same result, instead of referencing the MigratedVMs folder the item is 'vm' which I believe is the root folder correct?

                             

                            The environment is pretty clean/new and there aren't any resource pools in the mix.

                            • 11. Re: Scripting batch import of VM's using vmx
                              LucD Guru
                              Community WarriorsUser ModeratorsvExpert

                              There is always the Resources resourcepool, when you have a cluster.
                              The method seems to want to go to a resourcepool with pool = 'vim.ResourcePool:resgroup-27'

                              Does that correspond with the current Resources resourcepool?

                              Do a

                               

                              Get-View -ViewType ResourcePool

                               

                              • 12. Re: Scripting batch import of VM's using vmx
                                vJoeG Hot Shot
                                VMware Employees

                                From the client. Sorry for the delays. I'm working remotely today

                                 

                                GetView-ResPool-01.png

                                • 13. Re: Scripting batch import of VM's using vmx
                                  LucD Guru
                                  vExpertUser ModeratorsCommunity Warriors

                                  The resourcepool seems to be ok, it is showing the same MoRef as the one in vpxd log.


                                  On another note, is this error happening with all VMX files, or just this one?

                                  • 14. Re: Scripting batch import of VM's using vmx
                                    vJoeG Hot Shot
                                    VMware Employees

                                    We have tried all 3 VM's that are in the new environment. 500 more once the scripting is working properly.

                                     

                                    What's has me shaking my head is Monday we ran the command on EDE-90010 and EDE-90011 successfully.

                                     

                                    Wednesday, when we tried to incorporate it into the script is when the error started.

                                     

                                    Maybe worth noting, if we register the VMX files for all 3 from the vCenter GUI they work fine.

                                    1 2 Previous Next