none
Powershell ISE. Script that creates a VM from template inn the specified Datacenter RRS feed

  • Question

  • I need help solving this error

    New-VM : 07.05.2019 14.01.12 New-VM Template parameter: Could not find any of the objects specified by name.
    At C:\Powershell-scripts\Script that creates a VM from template inn the specified Datacenter.ps1:20 char:1
    + New-VM -Name $VMName -Template $VMtemplate -VMHost (get-vmhost)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (VMware.VimAutom...mplate Template:RuntimePropertyInfo) [New-VM], ObnRecordProcessingFailedException
        + FullyQualifiedErrorId : Core_ObnSelector_SetNewParameterValue_ObjectNotFoundCritical,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

    This is the script

    # Virtual Center Details
    $server_address = "192.168.1.113"
    $username = "RødtBord@vsphere.local"
    $password = "123"

    #TemplateName : Name of the Template which is used for the VM deployment
    #VMName  : The Name to be used for the new VM creation
    #VMtemplate : specifies what Datacenter the template is located in. And searches for templates whose names start with Martin

    $TemplateName = "Martin windows 10"
    $VMName = "MWindwos10test"
    $VMtemplate = "Get-Template -name Martin* -Datastore 'Host 44'"

    #Connecting to the VI Server

    Connect-VIServer -server $server_address -User $username -Password $password

    #Creates a new vm using a specified template

    New-VM -Name $VMName -Template $VMtemplate -VMHost (get-vmhost)

    #Starts the VM we just created with the template

    Get-VM -Name $VMName | Start-VM

    • Moved by Bill_Stewart Wednesday, September 4, 2019 9:46 PM Unanswerable drive-by question
    Tuesday, May 7, 2019 12:07 PM

All replies