Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 178257

Powercli 6 sees multiple objects from get-template in run .net script activity

$
0
0

This issue only occurs  in system center Orchestrator 2012 sp1 run .net script activity.

Just upgraded to PowerCLi 6.3.0.8258, OS running powershell 3.0.

 

had to invoke-command all the runbook activities to run powercli code in 64bit.

All is well until I try the the new-VM command in a .net script activity.  The get-template command returns only 1 object, the correct template object, but new-vm command sees it as multiple values and not know what to do then dumps.  This entire script works just fine outside of orchestrator on the same server with identical creds.  Verified only one session in $defaultviserver.  Have tried run behavior in flatten/non-flatten mode, same thing.  I am hoping there is something simple I am overlooking, please advise if you have ran across this, thanx.

 

Here is the error in Log:
TemplatePath = Win10-Template
folderPath = Windows10
New-VM        Template parameter: Could not find any of the objects specified by name.
New-VM        The specified parameter 'Template' expects a single value, but your name criteria 'Win10-Template' corresponds to multiple values.

 

----------------------------------------------------------------------------------------------------------------------------

sample script below

-----------------------------------------------------------------------------------------------------------------------------

#invoke command for 64bit support for new powercli snapins
$result = Invoke-Command -ScriptBlock {

add-pssnapin vmware.vimautomation.core

$rmt_user = "runbook"
$rmt_password = "runbookpassword"
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($rmt_user, (ConvertTo-SecureString -String $rmt_password -AsPlainText -Force))

#Connects to vCenter/ESX(i)
$conn = connect-viserver "VcenterServer" -Credential $cred

$VMName = "EASTVM"
$Hostname = "host1"
$Datastore  = "store1"

$trace += "datacenter = $datacenter `r`n"
$trace += "hostname = $hostname `r`n"
$trace += "datastore = $datastore `r`n"
$trace += "vmname = $vmname `r`n"

$templatePath = (get-template -location EAST -name Win10-Template)
$FolderPath = get-folder -Location EAST -Name "Windows10"

$templatePath  = $templatePath -replace '\s',''
$FolderPath = $FolderPath -replace '\s',''
$trace += "TemplatePath = $templatepath `r`n"
$trace += "folderPath = $folderpath`r`n"
$trace

New-VM -Name $VMName -VMHost $Hostname -Datastore $Datastore -Template $templatePath
# -location $FolderPath
$Error

} -ComputerName localhost #end invoke command for 64bit support


Viewing all articles
Browse latest Browse all 178257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>