Powershell DSC:使用DSC脚本安装时出错

时间:2017-06-10 08:41:15

标签: powershell dsc

当我运行以下脚本时,它会安装Web Platform Installer并安装URLReWrite。但它最终以错误终止。

configuration SetupVm 
{ 
    node ("localhost") 
    { 
        Package WebPi_Installation
        {
            Ensure = "Present"
            Name = "Microsoft Web Platform Installer 5.0"
            Path = Join-Path $PSScriptRoot WebPlatformInstaller_amd64_en-US.msi
            ProductId = '4D84C195-86F0-4B34-8FDE-4A17EB41306A'
            Arguments = ''
            DependsOn = @("[WindowsFeature]IISMgmtConsole")
        }

        Package UrlRewrite
        {
            Ensure = "Present"
            Name = "URL Rewrite 2.0"
            Path = "C:\Program Files\Microsoft\Web Platform Installer\WebpiCmd-x64.exe"
            ProductId = ''
            Arguments = "/install /products:UrlRewrite2 /AcceptEula"
            DependsOn = @("[Package]WebPi_Installation")
        }
    } 
} 

SetupVm

Start-DscConfiguration -Path .\SetupVm -Wait -Verbose -Force
  

Validate-StandardArguments,Path是C:\ Program Files \ Microsoft \ Web Platform Installer \ WebpiCmd-x64.exe   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]路径扩展名为   。可执行程序   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]确保存在   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]产品是   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]产品为boolean为False   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]未安装包URL Rewrite 2.0   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]   Validate-StandardArguments,Path是C:\ Program Files \ Microsoft \ Web Platform Installer \ WebpiCmd-x64.exe   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]路径扩展名为.exe   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]包配置开始   VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]二进制文件是EXE

     

VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]使用/ install / products:UrlRewrite2 / AcceptEula

启动C:\ Program Files \ Microsoft \ Web Platform Installer \ WebpiCmd-x64.exe      

VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]启动过程   带参数/ install / products的C:\ Program Files \ Microsoft \ Web Platform Installer \ WebpiCmd-x64.exe:UrlRewrite2 / AcceptEula

     

VERBOSE:[tktestdsc4]:[[Package] UrlRewrite]机器需要重启   VERBOSE:[tktestdsc4]:LCM:[End Set] [[Package] UrlRewrite] in   55.5920秒。

     

PowerShell DSC资源MSFT_PackageResource无法执行    Set-TargetResource功能,包含错误消息:来自

的包      

C:\ Program Files \ Microsoft \ Web Platform Installer \ WebpiCmd-x64.exe是   已安装,但指定的ProductId和/或Name不是

     

匹配包裹详情

     
      
  • CategoryInfo:InvalidOperation:(:) [],CimException

  •   
  • FullyQualifiedErrorId:ProviderOperationExecutionFailure

  •   
  • PSComputerName:localhost

  •   
     

SendConfigurationApply功能未成功。

     
      
  • CategoryInfo:NotSpecified:(root / Microsoft / ... gurationManager:String)[],CimException

  •   
  • FullyQualifiedErrorId:MI RESULT 1

  •   
  • PSComputerName:localhost

  •   
     

VERBOSE:操作'调用CimMethod'完成。

     

VERBOSE:配置作业完成所需的时间为70.57秒

2 个答案:

答案 0 :(得分:1)

您没有指定productId,因此它尝试使用productId验证软件包是否已安装,并且(显然)失败。

如果产品没有productId,您可以使用脚本扩展程序安装它,如果有,请将productId添加到URL Rewrite资源

答案 1 :(得分:0)

对于任何再次访问此软件的人来说,对我们有用的解决方案是使用以下方法手动安装:

.\WebpiCmd-x64.exe /install /products:UrlRewrite2 /AcceptEula

,然后在powershell中运行以下命令:

get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, LocalPackage -AutoSize

导致:

{9BCA2118-F753-4A1E-BCF3-5A820729965C} IIS URL Rewrite Module 2

然后我们将此productId添加到具有相应名称等的dsc中:

Package URLRewriteInstallation
{
  Ensure = "Present"
  Name = "IIS URL Rewrite Module 2"
  Path = $Node.WebPiCmdPath
  ProductId = '9BCA2118-F753-4A1E-BCF3-5A820729965C'
  Arguments = "/install /products:UrlRewrite2 /AcceptEula"
  DependsOn = @("[Package]WebPlatformInstaller", "[Script]PIProxy")
}

并且urlrewrite已成功安装