解决方案 由于New-VM cmdlet本身已出现异常,因此最好联系VMware人们了解此异常的含义.不幸的是,它看起来像是一种包罗万象的异常.我还建议尝试捕获调试流,以查看是否在其中捕获了任何其他信息.由于Azure自动化不会记录调试流,因此您需要重定向流.指示这里.快速查看Bing似乎可以出于多种原因引发此异常,但是它们似乎都具有尝试访问缺少的或已经存在的资源的通用线程.尝试进行的另一个故障排除步骤是捕获流程监控器日志.由于该异常为您提供了它正在尝试查找的特定资源,因此procmon日志可能会帮助您提供一些线索,以了解它正试图对该资源执行的操作以及它是否确实丢失了 或存在访问问题或诸如此类的问题,其中吞没了真正的异常并将该通用异常替换为原来的位置. -杰夫. So I have installed a Azure Hybrid worker on my script server.I can launch a script with Local System / Local Service or Network Service as a scheduled task or interactively.But running it through Test Pane in fails on the Azure Runbook if fails with a rather non-informed errorNew-VM : 6/27/2018 4:05:30 PM New-VM Could not find item C:\ProgramData.At line:56 char:1+ New-VM -Name $VMname -template $myTemplate -location $env -ResourcePo ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [New-VM], VimException + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVMPaired it down my script , to make it simpleParam ([String]$VMNamesuffix = 'MyTestServerLocal', [string]$Env = "Test01",[String]$VCServiceAccount ="Domain\svc_UserAccount",[String]$VCServicePassword = "SomePassword")## Varaibles ##$VMname = ($Env+"-"+$VMNameSuffix).ToUpper()$sourcevc = "vcenter01.domain.test"$TargetDataStore = "TFC_XIO_"+$env $sourceDS = 'TFC_XIO_UTILITY'$ResourcePool = 'GoldRP'# List of modules to be loaded$moduleList = @( "VMware.VimAutomation.Core", "VMware.VimAutomation.Vds", "VMware.VimAutomation.Cloud", "VMware.VimAutomation.PCloud", "VMware.VimAutomation.Cis.Core", "VMware.VimAutomation.Storage", "VMware.VimAutomation.HorizonView", "VMware.VimAutomation.HA", "VMware.VimAutomation.vROps", "VMware.VumAutomation", "VMware.DeployAutomation", "VMware.ImageBuilder", "VMware.VimAutomation.License" )# Load modulesfunction LoadModules(){ $loaded = Get-Module -Name $moduleList -ErrorAction Ignore | % {$_.Name} $registered = Get-Module -Name $moduleList -ListAvailable -ErrorAction Ignore | % {$_.Name} $notLoaded = $registered | ? {$loaded -notcontains $_} foreach ($module in $registered) { if ($loaded -notcontains $module) { Import-Module $module } }}#Run LoadModules functionLoadModules$VCSecurePassword = Convertto-SecureString -String $VCServicePassword -AsPlainText -force$VCCreds = New-object System.Management.Automation.PSCredential $VCServiceAccount ,$VCSecurePasswordConnect-VIServer -Server $sourcevc -Credential $VCCreds$SourceDataStoreOB = Get-Datastore $SourceDataStore$TargetDataStoreOB= Get-Datastore $TargetDataStore$myTemplate = Get-Template -Name "WinTemplate" -Location TemplatesNew-VM -Name $VMname -template $myTemplate -location $env -ResourcePool $ResourcePool -Datastore $TargetDataStoreOB -Verbose 解决方案 Since the exception is coming out of the New-VM cmdlet itself it might be better to reach out to the VMware folks to find out what this exception means. Unfortunately it looks like some kind of a catch-all exception.I would also recommend to try capturing debug streams to see if any additional information is captured there. Since Azure Automation doesn't log debug streams you'll need to redirect the streams. Instructionshere.Doing some quick Bing sleuthing it appears that this exception can be thrown for a number of varying reasons but they all seem to have a common thread of attempting to access a resource that is either missing, or already exists.Another troubleshooting step to try would be to capture a Process Monitor log. Since the exception is giving you a specific resource that it is trying to find, the procmon log might help to give you some clues as to what exactly it is trying to do with that resource and whether or not it really is missing or if there was an access issue or something like that where the real exception has been swallowed and this generic exception thrown in its place.-Jeff. 这篇关于PowerCLI"New-VM"在Hybrid Worker上失败,但同时充当计划任务和交互Powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 09:18