问题:在Azure DevOps的Powershell任务中生成LCM MOF或DSC配置MOF
说明:因此,通常情况下,您只需调用dsc配置,即myconfig.ps1,并且在文件中已经提到了dsc配置NAME。 之后,它将生成MOF文件。 如果执行相同的操作,则在Powershell Task中调用此myconfiguration.ps1文件(内嵌任务相同错误),它将不会生成该文件。
样本: 请参阅下面的示例代码,该示例代码已保存在.ps1文件中
Configuration myconfig
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Service OIService
{
Ensure = "Present"
Name = "HealthService"
State = "Running"
}
}
myconfig -OutputPath c:\myconfig
通过azuredevops中的powershell任务调用myconfig.ps1文件,将导致以下错误。
错误:
在C:\ agent_work \ 1 \ s \ Scripts-VSTS \ DSCDeploy \ myconfig.ps1:2 char:15
+配置myconfig {
+ ~~~
System.Management.Automation.PSArgumentException:无法处理参数,因为参数“ fullFilePath”的值
无效。更改“ fullFilePath”参数的值,然后再次运行该操作。
在Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser.GetFileContent(String fullFilePath)
在Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser.ParseSchemaMof(字符串filePath)
在Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.ImportClasses处(字符串路径,元组2 moduleIn
fo, Collection
1错误,布尔值importInBoxResourcesImplicitly)
在Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.Initialize(Collection 1 errors, List
1 modu
lePathList)
在Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Dictionary 2 functio
nsToDefine, Collection
1错误,List 1 modulePathList, Boolean cacheResourcesFromMultipleModuleVersions)
at System.Management.Automation.Language.Parser.ConfigurationStatementRule(IEnumerable
1 customAttributes,令牌con
figurationToken)
在C:\ agent_work \ 1 \ s \ Scripts-VSTS \ DSCDeploy \ myconfig.ps1:2 char:20
+配置myconfig {
+〜
意外的标记 '
在表达或陈述中。
在C:\ agent_work \ 1 \ s \ Scripts-VSTS \ DSCDeploy \ myconfig.ps1:16 char:1
+}
+〜
表达式或语句中出现意外的标记“}”。
+ CategoryInfo:ParserError:(:) [],ParentContainsErrorRecordException
+ FullyQualifiedErrorId:ParserError