PowerCLI

 View Only
Expand all | Collapse all

About creating virtual machines in parallel

  • 1.  About creating virtual machines in parallel

    Posted Apr 30, 2021 02:03 AM

    Use this script to create virtual machines, which are created one by one in order.
    How can I modify it to support parallel creation of virtual machines based on the following script?

    # Starting Script
    Write-Host ("Starting Script: {0}" -f (Get-Date -format 'u'))
    $startTime = Get-Date

    ######################## SECTION A
    # Make errors to be terminating. Otherwise some won't be caught.
    $ErrorActionPreference = "Stop"
    Try {
    # Specify the location of the CSV file.
    $CSVFile = "C:\Deploy-Linux-VMs-1NIC.csv"
    $CSVVm = Import-Csv $CSVFile
    ForEach ($CSVRow in $CSVVm) {
    ######################## SECTION B
    # Verifying that the input is correct and that the VM name is not already in use.
    $VmTemplate = Get-Template $CSVRow.TEMPLATE
    $VmPortgroup1 = Get-VirtualPortGroup -Name $CSVRow.PORTGROUP1
    $VmDatastore = Get-Datastore $CSVRow.DATASTORE
    $VmCluster = Get-Cluster $CSVRow.CLUSTER | Where DrsAutomationLevel -ne "manual"
    if (Get-VM $CSVRow.VMName -ErrorAction SilentlyContinue) {Throw "A virtual machine with name $($CSVRow.VMNAME) already exists"}
    ######################## SECTION C
    # Cloning existing custom specs to a temporary one
    $CustomSpec = New-OSCustomizationSpec -OSCustomizationSpec "rhel7-custspec" -Name (New-Guid | Select -ExpandProperty guid) -Type NonPersistent
    ######################## SECTION D
    # Configuring the network settings in the custom specs
    $CustomSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $CSVRow.IP1 -SubnetMask $CSVRow.MASK1 -DefaultGateway $CSVRow.GATEWAY1
    ######################## SECTION E
    # Deploying the VM
    $NewVM = New-VM -Template $VmTemplate -OSCustomizationSpec $CustomSpec -ResourcePool $VmCluster -Datastore $VmDatastore -Name $CSVRow.VMNAME
    ######################## SECTION F
    # Connecting the correct PortGroup
    $NewVM | Get-NetworkAdapter | Set-NetworkAdapter -StartConnected $true -Confirm:$false -NetworkName $CSVRow.PORTGROUP1
    ######################## SECTION G
    # Starting the VM
    $NewVM | Start-VM
    }
    } CATCH {
    ######################## SECTION H
    Write-Error $_.Exception -ErrorAction stop
    }

    # End Script
    $endTime = Get-Date
    $totalSeconds = "{0:N4}" -f ($endTime - $startTime).TotalSeconds
    Write-Host "All Jobs Finished in $totalSeconds Seconds"



  • 2.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 05:44 AM

    There are a couple of options.
    You can use Start-Job, to run several jobs in the background in parallel.

    When you are on PowerShell 7 and using at least PowerCLI 12.2, you can use Foreach -Parallel.



  • 3.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 11:49 AM

    I use the -Parallel parameter and the prompt is as follows:

    ParserError:
    Line |
    5 | ForEach -Parallel($CSVRow in $CSVVm) {
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | The foreach '-parallel' parameter is reserved for future use.

    PS C:\Users\Administrator>

    I don't know why……

    #####################################

    My PowerCLI Environment is:

    PS C:\Users\Administrator> $PSVersionTable.PSVersion

    Major Minor Patch PreReleaseLabel BuildLabel
    ----- ----- ----- --------------- ----------
    7 1 3

    PS C:\Users\Administrator> $host.version

    Major Minor Build Revision
    ----- ----- ----- --------
    7 1 3 -1

    PS C:\Users\Administrator>

     

    PS C:\Users\Administrator> Get-Module VMware* -ListAvailable

    Directory: C:\Users\Administrator\Documents\PowerShell\Modules

    ModuleType Version PreRelease Name PSEdition ExportedCommands
    ---------- ------- ---------- ---- --------- ----------------
    Script 12.2.0.17… VMware.CloudServices Desk {Connect-Vcs, Disconnect-Vcs, Get-VcsOrganizationRole, Get-VcsService…}
    Script 7.0.2.178… VMware.DeployAutomation Desk {Add-CustomCertificate, Add-DeployRule, Add-ProxyServer, Add-ScriptBundle…}
    Script 6.7.0.112… VMware.DeployAutomation Desk {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-DeployRule…}
    Script 7.0.2.178… VMware.ImageBuilder Desk {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile…}
    Script 6.7.0.112… VMware.ImageBuilder Desk {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile…}
    Manifest 12.3.0.17… VMware.PowerCLI Desk
    Manifest 11.5.0.14… VMware.PowerCLI Desk
    Script 7.0.2.178… VMware.Vim Desk
    Script 6.7.0.148… VMware.Vim Desk
    Script 12.3.0.17… VMware.VimAutomation.Cis.Core Desk {Connect-CisServer, Disconnect-CisServer, Get-CisService}
    Script 11.5.0.14… VMware.VimAutomation.Cis.Core Desk {Connect-CisServer, Disconnect-CisServer, Get-CisService}
    Script 12.0.0.15… VMware.VimAutomation.Cloud Desk {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog…}
    Script 11.0.0.10… VMware.VimAutomation.Cloud Desk {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog…}
    Script 12.3.0.17… VMware.VimAutomation.Common Desk {Get-PowerCLIContext, Get-Task, New-OAuthSecurityContext, Stop-Task…}
    Script 11.5.0.14… VMware.VimAutomation.Common Desk {Get-Task, Stop-Task, Wait-Task}
    Script 12.3.0.17… VMware.VimAutomation.Core Desk {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
    Script 11.5.0.14… VMware.VimAutomation.Core Desk {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
    Script 12.3.0.17… VMware.VimAutomation.Hcx Desk {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance, Get-HCXComputeProfile…}
    Script 11.5.0.14… VMware.VimAutomation.Hcx Desk {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance, Get-HCXComputeProfile…}
    Script 12.3.0.17… VMware.VimAutomation.HorizonView Desk {Connect-HVServer, Disconnect-HVServer}
    Script 7.10.0.14… VMware.VimAutomation.HorizonView Desk {Connect-HVServer, Disconnect-HVServer}
    Script 12.0.0.15… VMware.VimAutomation.License Desk Get-LicenseDataManager
    Script 11.3.0.13… VMware.VimAutomation.License Desk Get-LicenseDataManager
    Script 12.3.0.17… VMware.VimAutomation.Nsxt Desk {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtGlobalManagerService, Get-NsxtPolicyService…}
    Script 11.5.0.14… VMware.VimAutomation.Nsxt Desk {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtPolicyService, Get-NsxtService}
    Script 12.2.0.17… VMware.VimAutomation.Sdk Desk Get-ErrorReport
    Script 11.5.0.14… VMware.VimAutomation.Sdk Desk {Get-ErrorReport, Get-PSVersion, Get-InstallPath}
    Script 12.3.0.17… VMware.VimAutomation.Security Desk {Add-AttestationServiceInfo, Add-KeyProviderServiceInfo, Add-TrustAuthorityKeyProviderServer, Add-TrustAuthorityKeyProviderServerCertificate…}
    Script 11.0.0.10… VMware.VimAutomation.Security Desk {Get-SecurityInfo, Get-VTpm, Get-VTpmCertificate, Get-VTpmCSR…}
    Script 12.3.0.17… VMware.VimAutomation.Srm Desk {Connect-SrmServer, Disconnect-SrmServer}
    Script 11.5.0.14… VMware.VimAutomation.Srm Desk {Connect-SrmServer, Disconnect-SrmServer}
    Script 12.3.0.17… VMware.VimAutomation.Storage Desk {Add-EntityDefaultKeyProvider, Add-KeyManagementServer, Add-VsanFileServiceOvf, Add-VsanObjectToRepairQueue…}
    Script 11.5.0.14… VMware.VimAutomation.Storage Desk {Add-KeyManagementServer, Add-VsanObjectToRepairQueue, Copy-VDisk, Export-SpbmStoragePolicy…}
    Script 1.6.0.0 VMware.VimAutomation.StorageUtility Desk Update-VmfsDatastore
    Script 1.3.0.0 VMware.VimAutomation.StorageUtility Desk Update-VmfsDatastore
    Script 12.3.0.17… VMware.VimAutomation.Vds Desk {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch…}
    Script 11.2.0.12… VMware.VimAutomation.Vds Desk {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch…}
    Script 12.2.0.17… VMware.VimAutomation.Vmc Desk {Add-VmcSddcHost, Connect-Vmc, Disconnect-Vmc, Get-AwsAccount…}
    Script 11.5.0.14… VMware.VimAutomation.Vmc Desk {Add-VmcSddcHost, Connect-Vmc, Disconnect-Vmc, Get-AwsAccount…}
    Script 12.2.0.17… VMware.VimAutomation.vROps Desk {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition…}
    Script 10.0.0.78… VMware.VimAutomation.vROps Desk {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition…}
    Script 12.3.0.17… VMware.VimAutomation.WorkloadManag… Desk {Disable-WMCluster, Enable-WMCluster, Get-WMCluster, Get-WMNamespace…}
    Script 12.1.0.16… VMware.VumAutomation Desk {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance…}
    Script 6.5.1.786… VMware.VumAutomation Desk {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance…}

    PS C:\Users\Administrator>



  • 4.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 11:55 AM

    You are not using it correctly, that should be

    $CSVVm | ForEach-Object -Parallel {
       # your code
    }


  • 5.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 12:17 PM

    I use “$CSVVm | ForEach-Object -Parallel”

    ($CSVRow in $CSVVm) will be invalid

    Variables like "$CSVRow.DATASTORE" ……etc, will not be quoted

    "ForEach ($CSVRow in $CSVVm)" can refer to $CSVRow



  • 6.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 12:22 PM

    Inside the codeblock you use $_.DATASTORE



  • 7.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 12:35 PM

    I do not know where the problem

    Thank you for quickly replying to me and helping me.

    微信截图_20210430203236.png



  • 8.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 01:56 PM

    As per the error, you have not connected to vCenter



  • 9.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 02:08 PM

    PS C:\Users\Administrator> Connect-VIServer vc01-a.corp.local -User Administrator@vsphere.local -Password P@ssword123

    Name Port User
    ---- ---- ----
    vc01-a.corp.local 443 VSPHERE.LOCAL\Administrator

    PS C:\Users\Administrator> # Starting Script
    PS C:\Users\Administrator> Write-Host ("Starting Script: {0}" -f (Get-Date -format 'u'))
    Starting Script: 2021-04-30 22:02:19Z
    PS C:\Users\Administrator> $startTime = Get-Date
    PS C:\Users\Administrator>
    PS C:\Users\Administrator> ######################## SECTION A
    PS C:\Users\Administrator> # Make errors to be terminating. Otherwise some won't be caught.
    PS C:\Users\Administrator> $ErrorActionPreference = "Stop"
    PS C:\Users\Administrator> Try {
    >> # Specify the location of the CSV file.
    >> $CSVFile = "C:\Deploy-Linux-VMs-1NIC.csv"
    >> $CSVVm = Import-Csv $CSVFile
    >> $CSVVm | ForEach-Object -Parallel {
    >> ######################## SECTION B
    >> # Verifying that the input is correct and that the VM name is not already in use.
    >> $VmTemplate = Get-Template $_.Name
    >> $VmPortgroup1 = Get-VirtualPortGroup $_.PORTGROUP1
    >> $VmDatastore = Get-Datastore $_.DATASTORE
    >> $VmCluster = Get-Cluster $_.CLUSTER | Where DrsAutomationLevel -ne "manual"
    >> if (Get-VM $_.VMName -ErrorAction SilentlyContinue) {Throw "A virtual machine with name $($_.VMNAME) already exists"}
    >> ######################## SECTION C
    >> # Cloning existing custom specs to a temporary one
    >> $CustomSpec = New-OSCustomizationSpec -OSCustomizationSpec "rhel7-custspec" -Name (New-Guid | Select -ExpandProperty guid) -Type NonPersistent
    >> ######################## SECTION D
    >> # Configuring the network settings in the custom specs
    >> $CustomSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_.IP1 -SubnetMask $_.MASK1 -DefaultGateway $_.GATEWAY1
    >> ######################## SECTION E
    >> # Deploying the VM
    >> $NewVM = New-VM -Template $VmTemplate -OSCustomizationSpec $CustomSpec -ResourcePool $VmCluster -Datastore $VmDatastore -Name $_.VMNAME
    >> ######################## SECTION F
    >> # Connecting the correct PortGroup
    >> $NewVM | Get-NetworkAdapter | Set-NetworkAdapter -StartConnected $true -Confirm:$false -NetworkName $_.PORTGROUP1
    >> ######################## SECTION G
    >> # Starting the VM
    >> $NewVM | Start-VM
    >> }
    >> } CATCH {
    >> ######################## SECTION H
    >> Write-Error $_.Exception -ErrorAction stop
    >> }
    Write-Error:
    Line |
    31 | Write-Error $_.Exception -ErrorAction stop
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | System.Management.Automation.CommandNotFoundException: The 'Get-Template' command was found in the module 'VMware.VimAutomation.Core', but the module could not be loaded. For more information, run 'Import-Module VMware.VimAutomation.Core'.
    ---> System.Management.Automation.CmdletInvocationException: Collection was modified; enumeration operation may not execute.
    ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
    at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
    at System.Management.Automation.PSModuleInfo.get_ExportedCmdlets()
    at System.Management.Automation.PSModuleInfo.get_ExportedCommands()
    at System.Management.Automation.AnalysisCache.CacheModuleExports(PSModuleInfo module, ExecutionContext context)
    at Microsoft.PowerShell.Commands.ModuleCmdletBase.CreateModuleInfoForGetModule(String file, Boolean refresh)
    at Microsoft.PowerShell.Commands.ModuleCmdletBase.GetModulesFromOneModulePath(List`1 names, String modulePath, Boolean all, Boolean refresh)+MoveNext()
    at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
    at System.Linq.OrderedEnumerable`1.GetEnumerator()+MoveNext()
    at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
    at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
    at Microsoft.PowerShell.Commands.ModuleCmdletBase.GetModule(String[] names, Boolean all, Boolean refresh)
    at Microsoft.PowerShell.Commands.GetModuleCommand.GetAvailableLocallyModules(String[] names, IDictionary`2 moduleSpecTable, Boolean all)
    at Microsoft.PowerShell.Commands.GetModuleCommand.ProcessRecord()
    at System.Management.Automation.CommandProcessor.ProcessRecord()
    --- End of inner exception stack trace ---
    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
    at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
    at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
    at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
    at System.Management.Automation.PowerShell.Invoke[T]()
    at System.Management.Automation.CommandDiscovery.AutoloadSpecifiedModule(String moduleName, ExecutionContext context, SessionStateEntryVisibility visibility, Exception& exception)
    --- End of inner exception stack trace ---
    at System.Management.Automation.CommandDiscovery.TryModuleAutoDiscovery(String commandName, ExecutionContext context, String originalCommandName, CommandOrigin commandOrigin, SearchResolutionOptions searchResolutionOptions, CommandTypes commandTypes, Exception& lastError)
    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
    at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
    at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
    at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    PS C:\Users\Administrator>
    PS C:\Users\Administrator> # End Script
    PS C:\Users\Administrator> $endTime = Get-Date
    PS C:\Users\Administrator> $totalSeconds = "{0:N4}" -f ($endTime - $startTime).TotalSeconds
    PS C:\Users\Administrator> Write-Host "All Jobs Finished in $totalSeconds Seconds"
    All Jobs Finished in 0.7121 Seconds
    PS C:\Users\Administrator> Import-Csv C:\Deploy-Windows-VMs-1NIC.csv | Format-Table
    Import-Csv: Could not find file 'C:\Deploy-Windows-VMs-1NIC.csv'.
    PS C:\Users\Administrator> Import-Csv C:\Deploy-Linux-VMs-1NIC.csv | Format-Table

    VMNAME TEMPLATE IP1 MASK1 GATEWAY1 DNS CLUSTER DATASTORE PORTGROUP1
    ------ -------- --- ----- -------- --- ------- --------- ----------
    mariadb01 rhel7-template 192.168.50.81 255.255.255.0 192.168.50.254 223.5.5.5 C01-A c01-01-a-local-3 VM Network
    tomcat01 rhel7-template 192.168.50.82 255.255.255.0 192.168.50.254 223.5.5.5 C01-A c01-01-a-local-3 VM Network
    nginx01 rhel7-template 192.168.50.83 255.255.255.0 192.168.50.254 223.5.5.5 C01-A c01-01-a-local-3 VM Network

    PS C:\Users\Administrator>



  • 10.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 02:10 PM

    Did you install the PowerCLI module from the ZIP file?

    Did you unlock the ZIP file after the download?



  • 11.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 02:36 PM

    I use online install

    Install-Module -Name VMware.PowerCLI

     

    PS C:\Users\Administrator> Get-Module VMware* -ListAvailable

    Directory: C:\Users\Administrator\Documents\PowerShell\Modules

    ModuleType Version PreRelease Name PSEdition ExportedCommands
    ---------- ------- ---------- ---- --------- ----------------
    Script 12.2.0.17… VMware.CloudServices Desk {Connect-Vcs, Disconnect-Vcs, Get-VcsOrganizationRole, Get-VcsService…}
    Script 7.0.2.178… VMware.DeployAutomation Desk {Add-CustomCertificate, Add-DeployRule, Add-ProxyServer, Add-ScriptBundle…}
    Script 7.0.2.178… VMware.ImageBuilder Desk {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile…}
    Manifest 12.3.0.17… VMware.PowerCLI Desk
    Script 7.0.2.178… VMware.Vim Desk
    Script 12.3.0.17… VMware.VimAutomation.Cis.Core Desk {Connect-CisServer, Disconnect-CisServer, Get-CisService}
    Script 12.0.0.15… VMware.VimAutomation.Cloud Desk {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog…}
    Script 12.3.0.17… VMware.VimAutomation.Common Desk {Get-PowerCLIContext, Get-Task, New-OAuthSecurityContext, Stop-Task…}
    Script 12.3.0.17… VMware.VimAutomation.Core Desk {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
    Script 12.3.0.17… VMware.VimAutomation.Hcx Desk {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance, Get-HCXComputeProfile…}
    Script 12.3.0.17… VMware.VimAutomation.HorizonView Desk {Connect-HVServer, Disconnect-HVServer}
    Script 12.0.0.15… VMware.VimAutomation.License Desk Get-LicenseDataManager
    Script 12.3.0.17… VMware.VimAutomation.Nsxt Desk {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtGlobalManagerService, Get-NsxtPolicyService…}
    Script 12.2.0.17… VMware.VimAutomation.Sdk Desk {Get-ErrorReport, EnableParameterCompleters, Get-InstallPath, Get-PSVersion}
    Script 12.3.0.17… VMware.VimAutomation.Security Desk {Add-AttestationServiceInfo, Add-KeyProviderServiceInfo, Add-TrustAuthorityKeyProviderServer, Add-TrustAuthorityKeyProviderServerCertificate…}
    Script 12.3.0.17… VMware.VimAutomation.Srm Desk {Connect-SrmServer, Disconnect-SrmServer}
    Script 12.3.0.17… VMware.VimAutomation.Storage Desk {Add-EntityDefaultKeyProvider, Add-KeyManagementServer, Add-VsanFileServiceOvf, Add-VsanObjectToRepairQueue…}
    Script 1.6.0.0 VMware.VimAutomation.StorageUtility Desk Update-VmfsDatastore
    Script 12.3.0.17… VMware.VimAutomation.Vds Desk {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch…}
    Script 12.2.0.17… VMware.VimAutomation.Vmc Desk {Add-VmcSddcHost, Connect-Vmc, Disconnect-Vmc, Get-AwsAccount…}
    Script 12.2.0.17… VMware.VimAutomation.vROps Desk {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition…}
    Script 12.3.0.17… VMware.VimAutomation.WorkloadManag… Desk {Disable-WMCluster, Enable-WMCluster, Get-WMCluster, Get-WMNamespace…}
    Script 12.1.0.16… VMware.VumAutomation Desk {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance…}

    PS C:\Users\Administrator>



  • 12.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 03:01 PM

    Due you get any info when you do the following

    Import-Module -Name VMware.VimAutomation.Core -Verbose
    


  • 13.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 03:10 PM

    PS C:\Users\Administrator> Import-Module -Name VMware.VimAutomation.Core -Verbose
    VERBOSE: Loading module from path 'C:\Users\Administrator\Documents\PowerShell\Modules\VMware.VimAutomation.Core\12.3.0.17839688\VMware.VimAutomation.Core.psd1'.
    VERBOSE: Importing cmdlet 'Add-PassthroughDevice'.
    VERBOSE: Importing cmdlet 'Add-VirtualSwitchPhysicalNetworkAdapter'.
    VERBOSE: Importing cmdlet 'Add-VMHost'.
    VERBOSE: Importing cmdlet 'Add-VMHostNtpServer'.
    VERBOSE: Importing cmdlet 'Connect-VIServer'.
    VERBOSE: Importing cmdlet 'Copy-ContentLibraryItem'.
    VERBOSE: Importing cmdlet 'Copy-DatastoreItem'.
    VERBOSE: Importing cmdlet 'Copy-HardDisk'.
    VERBOSE: Importing cmdlet 'Copy-VMGuestFile'.
    VERBOSE: Importing cmdlet 'Disconnect-VIServer'.
    VERBOSE: Importing cmdlet 'Dismount-Tools'.
    VERBOSE: Importing cmdlet 'Export-ContentLibraryItem'.
    VERBOSE: Importing cmdlet 'Export-LcmClusterDesiredState'.
    VERBOSE: Importing cmdlet 'Export-VApp'.
    VERBOSE: Importing cmdlet 'Export-VMHostProfile'.
    VERBOSE: Importing cmdlet 'Format-VMHostDiskPartition'.
    VERBOSE: Importing cmdlet 'Get-AdvancedSetting'.
    VERBOSE: Importing cmdlet 'Get-AlarmAction'.
    VERBOSE: Importing cmdlet 'Get-AlarmActionTrigger'.
    VERBOSE: Importing cmdlet 'Get-AlarmDefinition'.
    VERBOSE: Importing cmdlet 'Get-AlarmTrigger'.
    VERBOSE: Importing cmdlet 'Get-Annotation'.
    VERBOSE: Importing cmdlet 'Get-CDDrive'.
    VERBOSE: Importing cmdlet 'Get-Cluster'.
    VERBOSE: Importing cmdlet 'Get-ContentLibrary'.
    VERBOSE: Importing cmdlet 'Get-ContentLibraryItem'.
    VERBOSE: Importing cmdlet 'Get-CustomAttribute'.
    VERBOSE: Importing cmdlet 'Get-Datacenter'.
    VERBOSE: Importing cmdlet 'Get-Datastore'.
    VERBOSE: Importing cmdlet 'Get-DatastoreCluster'.
    VERBOSE: Importing cmdlet 'Get-DrsClusterGroup'.
    VERBOSE: Importing cmdlet 'Get-DrsRecommendation'.
    VERBOSE: Importing cmdlet 'Get-DrsRule'.
    VERBOSE: Importing cmdlet 'Get-DrsVMHostRule'.
    VERBOSE: Importing cmdlet 'Get-EsxCli'.
    VERBOSE: Importing cmdlet 'Get-EsxTop'.
    VERBOSE: Importing cmdlet 'Get-EventType'.
    VERBOSE: Importing cmdlet 'Get-FloppyDrive'.
    VERBOSE: Importing cmdlet 'Get-Folder'.
    VERBOSE: Importing cmdlet 'Get-HAPrimaryVMHost'.
    VERBOSE: Importing cmdlet 'Get-HardDisk'.
    VERBOSE: Importing cmdlet 'Get-Inventory'.
    VERBOSE: Importing cmdlet 'Get-IScsiHbaTarget'.
    VERBOSE: Importing cmdlet 'Get-LcmClusterDesiredStateRecommendation'.
    VERBOSE: Importing cmdlet 'Get-LcmHardwareCompatibility'.
    VERBOSE: Importing cmdlet 'Get-LcmImage'.
    VERBOSE: Importing cmdlet 'Get-Log'.
    VERBOSE: Importing cmdlet 'Get-LogType'.
    VERBOSE: Importing cmdlet 'Get-Metric'.
    VERBOSE: Importing cmdlet 'Get-NetworkAdapter'.
    VERBOSE: Importing cmdlet 'Get-NicTeamingPolicy'.
    VERBOSE: Importing cmdlet 'Get-OSCustomizationNicMapping'.
    VERBOSE: Importing cmdlet 'Get-OSCustomizationSpec'.
    VERBOSE: Importing cmdlet 'Get-OvfConfiguration'.
    VERBOSE: Importing cmdlet 'Get-PassthroughDevice'.
    VERBOSE: Importing cmdlet 'Get-PowerCLIConfiguration'.
    VERBOSE: Importing cmdlet 'Get-PowerCLIVersion'.
    VERBOSE: Importing cmdlet 'Get-ResourcePool'.
    VERBOSE: Importing cmdlet 'Get-ScsiController'.
    VERBOSE: Importing cmdlet 'Get-ScsiLun'.
    VERBOSE: Importing cmdlet 'Get-ScsiLunPath'.
    VERBOSE: Importing cmdlet 'Get-SecurityPolicy'.
    VERBOSE: Importing cmdlet 'Get-Snapshot'.
    VERBOSE: Importing cmdlet 'Get-Stat'.
    VERBOSE: Importing cmdlet 'Get-StatInterval'.
    VERBOSE: Importing cmdlet 'Get-StatType'.
    VERBOSE: Importing cmdlet 'Get-Tag'.
    VERBOSE: Importing cmdlet 'Get-TagAssignment'.
    VERBOSE: Importing cmdlet 'Get-TagCategory'.
    VERBOSE: Importing cmdlet 'Get-Template'.
    VERBOSE: Importing cmdlet 'Get-UsbDevice'.
    VERBOSE: Importing cmdlet 'Get-VApp'.
    VERBOSE: Importing cmdlet 'Get-VIAccount'.
    VERBOSE: Importing cmdlet 'Get-VICredentialStoreItem'.
    VERBOSE: Importing cmdlet 'Get-VIEvent'.
    VERBOSE: Importing cmdlet 'Get-View'.
    VERBOSE: Importing cmdlet 'Get-VIObjectByVIView'.
    VERBOSE: Importing cmdlet 'Get-VIPermission'.
    VERBOSE: Importing cmdlet 'Get-VIPrivilege'.
    VERBOSE: Importing cmdlet 'Get-VIProperty'.
    VERBOSE: Importing cmdlet 'Get-VIRole'.
    VERBOSE: Importing cmdlet 'Get-VirtualNetwork'.
    VERBOSE: Importing cmdlet 'Get-VirtualPortGroup'.
    VERBOSE: Importing cmdlet 'Get-VirtualSwitch'.
    VERBOSE: Importing cmdlet 'Get-VM'.
    VERBOSE: Importing cmdlet 'Get-VMGuest'.
    VERBOSE: Importing cmdlet 'Get-VMGuestDisk'.
    VERBOSE: Importing cmdlet 'Get-VMHost'.
    VERBOSE: Importing cmdlet 'Get-VMHostAccount'.
    VERBOSE: Importing cmdlet 'Get-VMHostAdvancedConfiguration'.
    VERBOSE: Importing cmdlet 'Get-VMHostAuthentication'.
    VERBOSE: Importing cmdlet 'Get-VMHostAvailableTimeZone'.
    VERBOSE: Importing cmdlet 'Get-VMHostDiagnosticPartition'.
    VERBOSE: Importing cmdlet 'Get-VMHostDisk'.
    VERBOSE: Importing cmdlet 'Get-VMHostDiskPartition'.
    VERBOSE: Importing cmdlet 'Get-VMHostFirewallDefaultPolicy'.
    VERBOSE: Importing cmdlet 'Get-VMHostFirewallException'.
    VERBOSE: Importing cmdlet 'Get-VMHostFirmware'.
    VERBOSE: Importing cmdlet 'Get-VMHostHardware'.
    VERBOSE: Importing cmdlet 'Get-VMHostHba'.
    VERBOSE: Importing cmdlet 'Get-VMHostModule'.
    VERBOSE: Importing cmdlet 'Get-VMHostNetwork'.
    VERBOSE: Importing cmdlet 'Get-VMHostNetworkAdapter'.
    VERBOSE: Importing cmdlet 'Get-VMHostNetworkStack'.
    VERBOSE: Importing cmdlet 'Get-VMHostNtpServer'.
    VERBOSE: Importing cmdlet 'Get-VMHostPatch'.
    VERBOSE: Importing cmdlet 'Get-VMHostPciDevice'.
    VERBOSE: Importing cmdlet 'Get-VMHostProfile'.
    VERBOSE: Importing cmdlet 'Get-VMHostProfileImageCacheConfiguration'.
    VERBOSE: Importing cmdlet 'Get-VMHostProfileRequiredInput'.
    VERBOSE: Importing cmdlet 'Get-VMHostProfileStorageDeviceConfiguration'.
    VERBOSE: Importing cmdlet 'Get-VMHostProfileUserConfiguration'.
    VERBOSE: Importing cmdlet 'Get-VMHostProfileVmPortGroupConfiguration'.
    VERBOSE: Importing cmdlet 'Get-VMHostRoute'.
    VERBOSE: Importing cmdlet 'Get-VMHostService'.
    VERBOSE: Importing cmdlet 'Get-VMHostSnmp'.
    VERBOSE: Importing cmdlet 'Get-VMHostStartPolicy'.
    VERBOSE: Importing cmdlet 'Get-VMHostStorage'.
    VERBOSE: Importing cmdlet 'Get-VMHostSysLogServer'.
    VERBOSE: Importing cmdlet 'Get-VMQuestion'.
    VERBOSE: Importing cmdlet 'Get-VMResourceConfiguration'.
    VERBOSE: Importing cmdlet 'Get-VMStartPolicy'.
    VERBOSE: Importing cmdlet 'Import-LcmClusterDesiredState'.
    VERBOSE: Importing cmdlet 'Import-VApp'.
    VERBOSE: Importing cmdlet 'Import-VMHostProfile'.
    VERBOSE: Importing cmdlet 'Install-VMHostPatch'.
    VERBOSE: Importing cmdlet 'Invoke-DrsRecommendation'.
    VERBOSE: Importing cmdlet 'Invoke-VMHostProfile'.
    VERBOSE: Importing cmdlet 'Invoke-VMScript'.
    VERBOSE: Importing cmdlet 'Mount-Tools'.
    VERBOSE: Importing cmdlet 'Move-Cluster'.
    VERBOSE: Importing cmdlet 'Move-Datacenter'.
    VERBOSE: Importing cmdlet 'Move-Datastore'.
    VERBOSE: Importing cmdlet 'Move-Folder'.
    VERBOSE: Importing cmdlet 'Move-HardDisk'.
    VERBOSE: Importing cmdlet 'Move-Inventory'.
    VERBOSE: Importing cmdlet 'Move-ResourcePool'.
    VERBOSE: Importing cmdlet 'Move-Template'.
    VERBOSE: Importing cmdlet 'Move-VApp'.
    VERBOSE: Importing cmdlet 'Move-VM'.
    VERBOSE: Importing cmdlet 'Move-VMHost'.
    VERBOSE: Importing cmdlet 'New-AdvancedSetting'.
    VERBOSE: Importing cmdlet 'New-AlarmAction'.
    VERBOSE: Importing cmdlet 'New-AlarmActionTrigger'.
    VERBOSE: Importing cmdlet 'New-AlarmDefinition'.
    VERBOSE: Importing cmdlet 'New-AlarmTrigger'.
    VERBOSE: Importing cmdlet 'New-CDDrive'.
    VERBOSE: Importing cmdlet 'New-Cluster'.
    VERBOSE: Importing cmdlet 'New-ContentLibrary'.
    VERBOSE: Importing cmdlet 'New-ContentLibraryItem'.
    VERBOSE: Importing cmdlet 'New-CustomAttribute'.
    VERBOSE: Importing cmdlet 'New-Datacenter'.
    VERBOSE: Importing cmdlet 'New-Datastore'.
    VERBOSE: Importing cmdlet 'New-DatastoreCluster'.
    VERBOSE: Importing cmdlet 'New-DrsClusterGroup'.
    VERBOSE: Importing cmdlet 'New-DrsRule'.
    VERBOSE: Importing cmdlet 'New-DrsVMHostRule'.
    VERBOSE: Importing cmdlet 'New-FloppyDrive'.
    VERBOSE: Importing cmdlet 'New-Folder'.
    VERBOSE: Importing cmdlet 'New-HardDisk'.
    VERBOSE: Importing cmdlet 'New-IScsiHbaTarget'.
    VERBOSE: Importing cmdlet 'New-NetworkAdapter'.
    VERBOSE: Importing cmdlet 'New-OSCustomizationNicMapping'.
    VERBOSE: Importing cmdlet 'New-OSCustomizationSpec'.
    VERBOSE: Importing cmdlet 'New-ResourcePool'.
    VERBOSE: Importing cmdlet 'New-ScsiController'.
    VERBOSE: Importing cmdlet 'New-Snapshot'.
    VERBOSE: Importing cmdlet 'New-StatInterval'.
    VERBOSE: Importing cmdlet 'New-Tag'.
    VERBOSE: Importing cmdlet 'New-TagAssignment'.
    VERBOSE: Importing cmdlet 'New-TagCategory'.
    VERBOSE: Importing cmdlet 'New-Template'.
    VERBOSE: Importing cmdlet 'New-VApp'.
    VERBOSE: Importing cmdlet 'New-VICredentialStoreItem'.
    VERBOSE: Importing cmdlet 'New-VIPermission'.
    VERBOSE: Importing cmdlet 'New-VIProperty'.
    VERBOSE: Importing cmdlet 'New-VIRole'.
    VERBOSE: Importing cmdlet 'New-VirtualPortGroup'.
    VERBOSE: Importing cmdlet 'New-VirtualSwitch'.
    VERBOSE: Importing cmdlet 'New-VISamlSecurityContext'.
    VERBOSE: Importing cmdlet 'New-VM'.
    VERBOSE: Importing cmdlet 'New-VMHostAccount'.
    VERBOSE: Importing cmdlet 'New-VMHostNetworkAdapter'.
    VERBOSE: Importing cmdlet 'New-VMHostProfile'.
    VERBOSE: Importing cmdlet 'New-VMHostProfileVmPortGroupConfiguration'.
    VERBOSE: Importing cmdlet 'New-VMHostRoute'.
    VERBOSE: Importing cmdlet 'Open-VMConsoleWindow'.
    VERBOSE: Importing cmdlet 'Remove-AdvancedSetting'.
    VERBOSE: Importing cmdlet 'Remove-AlarmAction'.
    VERBOSE: Importing cmdlet 'Remove-AlarmActionTrigger'.
    VERBOSE: Importing cmdlet 'Remove-AlarmDefinition'.
    VERBOSE: Importing cmdlet 'Remove-CDDrive'.
    VERBOSE: Importing cmdlet 'Remove-Cluster'.
    VERBOSE: Importing cmdlet 'Remove-ContentLibrary'.
    VERBOSE: Importing cmdlet 'Remove-ContentLibraryItem'.
    VERBOSE: Importing cmdlet 'Remove-CustomAttribute'.
    VERBOSE: Importing cmdlet 'Remove-Datacenter'.
    VERBOSE: Importing cmdlet 'Remove-Datastore'.
    VERBOSE: Importing cmdlet 'Remove-DatastoreCluster'.
    VERBOSE: Importing cmdlet 'Remove-DrsClusterGroup'.
    VERBOSE: Importing cmdlet 'Remove-DrsRule'.
    VERBOSE: Importing cmdlet 'Remove-DrsVMHostRule'.
    VERBOSE: Importing cmdlet 'Remove-FloppyDrive'.
    VERBOSE: Importing cmdlet 'Remove-Folder'.
    VERBOSE: Importing cmdlet 'Remove-HardDisk'.
    VERBOSE: Importing cmdlet 'Remove-Inventory'.
    VERBOSE: Importing cmdlet 'Remove-IScsiHbaTarget'.
    VERBOSE: Importing cmdlet 'Remove-NetworkAdapter'.
    VERBOSE: Importing cmdlet 'Remove-OSCustomizationNicMapping'.
    VERBOSE: Importing cmdlet 'Remove-OSCustomizationSpec'.
    VERBOSE: Importing cmdlet 'Remove-PassthroughDevice'.
    VERBOSE: Importing cmdlet 'Remove-ResourcePool'.
    VERBOSE: Importing cmdlet 'Remove-Snapshot'.
    VERBOSE: Importing cmdlet 'Remove-StatInterval'.
    VERBOSE: Importing cmdlet 'Remove-Tag'.
    VERBOSE: Importing cmdlet 'Remove-TagAssignment'.
    VERBOSE: Importing cmdlet 'Remove-TagCategory'.
    VERBOSE: Importing cmdlet 'Remove-Template'.
    VERBOSE: Importing cmdlet 'Remove-UsbDevice'.
    VERBOSE: Importing cmdlet 'Remove-VApp'.
    VERBOSE: Importing cmdlet 'Remove-VICredentialStoreItem'.
    VERBOSE: Importing cmdlet 'Remove-VIPermission'.
    VERBOSE: Importing cmdlet 'Remove-VIProperty'.
    VERBOSE: Importing cmdlet 'Remove-VIRole'.
    VERBOSE: Importing cmdlet 'Remove-VirtualPortGroup'.
    VERBOSE: Importing cmdlet 'Remove-VirtualSwitch'.
    VERBOSE: Importing cmdlet 'Remove-VirtualSwitchPhysicalNetworkAdapter'.
    VERBOSE: Importing cmdlet 'Remove-VM'.
    VERBOSE: Importing cmdlet 'Remove-VMHost'.
    VERBOSE: Importing cmdlet 'Remove-VMHostAccount'.
    VERBOSE: Importing cmdlet 'Remove-VMHostNetworkAdapter'.
    VERBOSE: Importing cmdlet 'Remove-VMHostNtpServer'.
    VERBOSE: Importing cmdlet 'Remove-VMHostProfile'.
    VERBOSE: Importing cmdlet 'Remove-VMHostProfileVmPortGroupConfiguration'.
    VERBOSE: Importing cmdlet 'Remove-VMHostRoute'.
    VERBOSE: Importing cmdlet 'Restart-VM'.
    VERBOSE: Importing cmdlet 'Restart-VMGuest'.
    VERBOSE: Importing cmdlet 'Restart-VMHost'.
    VERBOSE: Importing cmdlet 'Restart-VMHostService'.
    VERBOSE: Importing cmdlet 'Set-AdvancedSetting'.
    VERBOSE: Importing cmdlet 'Set-AlarmDefinition'.
    VERBOSE: Importing cmdlet 'Set-Annotation'.
    VERBOSE: Importing cmdlet 'Set-CDDrive'.
    VERBOSE: Importing cmdlet 'Set-Cluster'.
    VERBOSE: Importing cmdlet 'Set-ContentLibrary'.
    VERBOSE: Importing cmdlet 'Set-ContentLibraryItem'.
    VERBOSE: Importing cmdlet 'Set-CustomAttribute'.
    VERBOSE: Importing cmdlet 'Set-Datacenter'.
    VERBOSE: Importing cmdlet 'Set-Datastore'.
    VERBOSE: Importing cmdlet 'Set-DatastoreCluster'.
    VERBOSE: Importing cmdlet 'Set-DrsClusterGroup'.
    VERBOSE: Importing cmdlet 'Set-DrsRule'.
    VERBOSE: Importing cmdlet 'Set-DrsVMHostRule'.
    VERBOSE: Importing cmdlet 'Set-FloppyDrive'.
    VERBOSE: Importing cmdlet 'Set-Folder'.
    VERBOSE: Importing cmdlet 'Set-HardDisk'.
    VERBOSE: Importing cmdlet 'Set-IScsiHbaTarget'.
    VERBOSE: Importing cmdlet 'Set-NetworkAdapter'.
    VERBOSE: Importing cmdlet 'Set-NicTeamingPolicy'.
    VERBOSE: Importing cmdlet 'Set-OSCustomizationNicMapping'.
    VERBOSE: Importing cmdlet 'Set-OSCustomizationSpec'.
    VERBOSE: Importing cmdlet 'Set-PowerCLIConfiguration'.
    VERBOSE: Importing cmdlet 'Set-ResourcePool'.
    VERBOSE: Importing cmdlet 'Set-ScsiController'.
    VERBOSE: Importing cmdlet 'Set-ScsiLun'.
    VERBOSE: Importing cmdlet 'Set-ScsiLunPath'.
    VERBOSE: Importing cmdlet 'Set-SecurityPolicy'.
    VERBOSE: Importing cmdlet 'Set-Snapshot'.
    VERBOSE: Importing cmdlet 'Set-StatInterval'.
    VERBOSE: Importing cmdlet 'Set-Tag'.
    VERBOSE: Importing cmdlet 'Set-TagCategory'.
    VERBOSE: Importing cmdlet 'Set-Template'.
    VERBOSE: Importing cmdlet 'Set-VApp'.
    VERBOSE: Importing cmdlet 'Set-VIPermission'.
    VERBOSE: Importing cmdlet 'Set-VIRole'.
    VERBOSE: Importing cmdlet 'Set-VirtualPortGroup'.
    VERBOSE: Importing cmdlet 'Set-VirtualSwitch'.
    VERBOSE: Importing cmdlet 'Set-VM'.
    VERBOSE: Importing cmdlet 'Set-VMHost'.
    VERBOSE: Importing cmdlet 'Set-VMHostAccount'.
    VERBOSE: Importing cmdlet 'Set-VMHostAdvancedConfiguration'.
    VERBOSE: Importing cmdlet 'Set-VMHostAuthentication'.
    VERBOSE: Importing cmdlet 'Set-VMHostDiagnosticPartition'.
    VERBOSE: Importing cmdlet 'Set-VMHostFirewallDefaultPolicy'.
    VERBOSE: Importing cmdlet 'Set-VMHostFirewallException'.
    VERBOSE: Importing cmdlet 'Set-VMHostFirmware'.
    VERBOSE: Importing cmdlet 'Set-VMHostHba'.
    VERBOSE: Importing cmdlet 'Set-VMHostModule'.
    VERBOSE: Importing cmdlet 'Set-VMHostNetwork'.
    VERBOSE: Importing cmdlet 'Set-VMHostNetworkAdapter'.
    VERBOSE: Importing cmdlet 'Set-VMHostNetworkStack'.
    VERBOSE: Importing cmdlet 'Set-VMHostProfile'.
    VERBOSE: Importing cmdlet 'Set-VMHostProfileImageCacheConfiguration'.
    VERBOSE: Importing cmdlet 'Set-VMHostProfileStorageDeviceConfiguration'.
    VERBOSE: Importing cmdlet 'Set-VMHostProfileUserConfiguration'.
    VERBOSE: Importing cmdlet 'Set-VMHostProfileVmPortGroupConfiguration'.
    VERBOSE: Importing cmdlet 'Set-VMHostRoute'.
    VERBOSE: Importing cmdlet 'Set-VMHostService'.
    VERBOSE: Importing cmdlet 'Set-VMHostSnmp'.
    VERBOSE: Importing cmdlet 'Set-VMHostStartPolicy'.
    VERBOSE: Importing cmdlet 'Set-VMHostStorage'.
    VERBOSE: Importing cmdlet 'Set-VMHostSysLogServer'.
    VERBOSE: Importing cmdlet 'Set-VMQuestion'.
    VERBOSE: Importing cmdlet 'Set-VMResourceConfiguration'.
    VERBOSE: Importing cmdlet 'Set-VMStartPolicy'.
    VERBOSE: Importing cmdlet 'Start-VApp'.
    VERBOSE: Importing cmdlet 'Start-VM'.
    VERBOSE: Importing cmdlet 'Start-VMHost'.
    VERBOSE: Importing cmdlet 'Start-VMHostService'.
    VERBOSE: Importing cmdlet 'Stop-VApp'.
    VERBOSE: Importing cmdlet 'Stop-VM'.
    VERBOSE: Importing cmdlet 'Stop-VMGuest'.
    VERBOSE: Importing cmdlet 'Stop-VMHost'.
    VERBOSE: Importing cmdlet 'Stop-VMHostService'.
    VERBOSE: Importing cmdlet 'Suspend-VM'.
    VERBOSE: Importing cmdlet 'Suspend-VMGuest'.
    VERBOSE: Importing cmdlet 'Suspend-VMHost'.
    VERBOSE: Importing cmdlet 'Test-LcmClusterCompliance'.
    VERBOSE: Importing cmdlet 'Test-LcmClusterHealth'.
    VERBOSE: Importing cmdlet 'Test-VMHostProfileCompliance'.
    VERBOSE: Importing cmdlet 'Test-VMHostSnmp'.
    VERBOSE: Importing cmdlet 'Update-Tools'.
    VERBOSE: Importing cmdlet 'Wait-Tools'.
    VERBOSE: Importing function 'HookGetViewAutoCompleter'.
    PS C:\Users\Administrator>



  • 14.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 04:27 PM

    That error can have many causes.
    Does it work when you set your ExecutionPolicy temporarily to Unrestricted?

    Another test you can do is try to import with the full path

    Import-Module C:\Users\Administrator\Documents\PowerShell\Modules\VMware.VimAutomation.Core\12.3.0.17839688\VMware.VimAutomation.Core.psd1

    Ultimately you try to do a full reinstall.
    First delete all PowerCLI modules from the File Manager, then do the Install-Module.



  • 15.  RE: About creating virtual machines in parallel

    Posted May 01, 2021 12:35 AM
    ######################## SECTION A
    # Make errors to be terminating. Otherwise some won't be caught.
    $ErrorActionPreference = "Stop"
    Try {
    # Specify the location of the CSV file.
    $CSVFile = "C:\Deploy-Linux-VMs-1NIC.csv"
    $CSVVm = Import-Csv $CSVFile
    $CSVVm | ForEach-Object {
        ######################## SECTION B
        # Verifying that the input is correct and that the VM name is not already in use.
        $VmTemplate = Get-Template $_.TEMPLATE
        $VmPortgroup1 = Get-VirtualPortGroup $_.PORTGROUP1
        $VmDatastore = Get-Datastore $_.DATASTORE
        $VmCluster = Get-Cluster $_.CLUSTER | Where DrsAutomationLevel -ne "manual"
        if (Get-VM $_.VMNAME -ErrorAction SilentlyContinue) {Throw "A virtual machine with name $($_.VMNAME) already exists"}
        ######################## SECTION C
        # Cloning existing custom specs to a temporary one
        $CustomSpec = New-OSCustomizationSpec -OSCustomizationSpec "rhel7-custspec" -Name (New-Guid | Select -ExpandProperty guid) -Type NonPersistent
        ######################## SECTION D
        # Configuring the network settings in the custom specs
        $CustomSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_.IP1 -SubnetMask $_.MASK1 -DefaultGateway $_.GATEWAY1
        ######################## SECTION E
        # Deploying the VM
        $NewVM = New-VM -Template $VmTemplate -OSCustomizationSpec $CustomSpec -ResourcePool $VmCluster -Datastore $VmDatastore -Name $_.VMNAME
        ######################## SECTION F
        # Connecting the correct PortGroup
        $NewVM | Get-NetworkAdapter | Set-NetworkAdapter -StartConnected $true -Confirm:$false -NetworkName $VmPortgroup1
        ######################## SECTION G
        # Starting the VM
        $NewVM | Start-VM
    }
    } CATCH {
        ######################## SECTION H
        Write-Error $_.Exception -ErrorAction stop
    }

     

    The results received by the implementation are as follows:

    Write-Error:
    Line |
      31 |      Write-Error $_.Exception -ErrorAction stop
         |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         | VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.VimException: 5/1/2021 8:29:39 AM   Get-VirtualPortGroup
    Could not find VMHost with name 'VM Network'.
    PS C:\Users\Administrator>
    PS C:\Users\Administrator> Get-ExecutionPolicy
    RemoteSigned
    PS C:\Users\Administrator> Get-PowerCLIConfiguration
    
    Scope    ProxyPolicy     DefaultVIServerMode InvalidCertificateAction  DisplayDeprecationWarnings WebOperationTimeout
                                                                                                      Seconds
    -----    -----------     ------------------- ------------------------  -------------------------- -------------------
    Session  UseSystemProxy  Multiple            Ignore                    True                       300
    User                     Multiple
    AllUsers                                     Ignore
    
    PS C:\Users\Administrator> Get-Module VMware* -ListAvailable
    
        Directory: C:\Users\Administrator\Documents\PowerShell\Modules
    
    ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
    ---------- -------    ---------- ----                                --------- ----------------
    Script     12.2.0.17…            VMware.CloudServices                Desk      {Connect-Vcs, Disconnect-Vcs, Get-VcsOrganizationRole, Get-VcsService…}
    Script     7.0.2.178…            VMware.DeployAutomation             Desk      {Add-CustomCertificate, Add-DeployRule, Add-ProxyServer, Add-ScriptBundle…}
    Script     7.0.2.178…            VMware.ImageBuilder                 Desk      {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile…}
    Manifest   12.3.0.17…            VMware.PowerCLI                     Desk
    Script     7.0.2.178…            VMware.Vim                          Desk
    Script     12.3.0.17…            VMware.VimAutomation.Cis.Core       Desk      {Connect-CisServer, Disconnect-CisServer, Get-CisService}
    Script     12.0.0.15…            VMware.VimAutomation.Cloud          Desk      {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog…}
    Script     12.3.0.17…            VMware.VimAutomation.Common         Desk      {Get-PowerCLIContext, Get-Task, New-OAuthSecurityContext, Stop-Task…}
    Script     12.3.0.17…            VMware.VimAutomation.Core           Desk      {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer…}
    Script     12.3.0.17…            VMware.VimAutomation.Hcx            Desk      {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance, Get-HCXComputeProfile…}
    Script     12.3.0.17…            VMware.VimAutomation.HorizonView    Desk      {Connect-HVServer, Disconnect-HVServer}
    Script     12.0.0.15…            VMware.VimAutomation.License        Desk      Get-LicenseDataManager
    Script     12.3.0.17…            VMware.VimAutomation.Nsxt           Desk      {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtGlobalManagerService, Get-NsxtPolicyService…}
    Script     12.2.0.17…            VMware.VimAutomation.Sdk            Desk      {Get-ErrorReport, Get-PSVersion, EnableParameterCompleters, Get-InstallPath}
    Script     12.3.0.17…            VMware.VimAutomation.Security       Desk      {Add-AttestationServiceInfo, Add-KeyProviderServiceInfo, Add-TrustAuthorityKeyProviderServer, Add-TrustAuthorityKeyProviderServerCertificate…}
    Script     12.3.0.17…            VMware.VimAutomation.Srm            Desk      {Connect-SrmServer, Disconnect-SrmServer}
    Script     12.3.0.17…            VMware.VimAutomation.Storage        Desk      {Add-EntityDefaultKeyProvider, Add-KeyManagementServer, Add-VsanFileServiceOvf, Add-VsanObjectToRepairQueue…}
    Script     1.6.0.0               VMware.VimAutomation.StorageUtility Desk      Update-VmfsDatastore
    Script     12.3.0.17…            VMware.VimAutomation.Vds            Desk      {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch…}
    Script     12.2.0.17…            VMware.VimAutomation.Vmc            Desk      {Add-VmcSddcHost, Connect-Vmc, Disconnect-Vmc, Get-AwsAccount…}
    Script     12.2.0.17…            VMware.VimAutomation.vROps          Desk      {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition…}
    Script     12.3.0.17…            VMware.VimAutomation.WorkloadManag… Desk      {Disable-WMCluster, Enable-WMCluster, Get-WMCluster, Get-WMNamespace…}
    Script     12.1.0.16…            VMware.VumAutomation                Desk      {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance…}
    
    PS C:\Users\Administrator>


  • 16.  RE: About creating virtual machines in parallel

    Posted May 01, 2021 06:23 AM

    I think the message is clear 

    Could not find VMHost with name 'VM Network'.

    There is an error in your input to the cmdlet



  • 17.  RE: About creating virtual machines in parallel

    Posted Apr 30, 2021 12:25 PM

    You might want to have a look at New Release – VMware PowerCLI 12.2

    The Foreach-Object -parallel{} is now supported section contains an example.