DSC does not install Git



我正在尝试使用DSC在Windows 7上使用PowerShell 4.0安装Git,基于:

https://justingalston.wordpress.com/2014/06/11/using-powershell-desired-state-configuration-to-check-for-and-install-applications/

Configuration InstallApps
{
  Node localhost
  {
    Package Git
    {
        Ensure = "Present"
        Name = "Git"
        Path = "C:tmpGit-2.7.0.2-64-bit.exe"
        ProductId = ''
    }
  }
}
InstallApps

Git 未安装在我运行上述脚本的计算机上。

当我运行上述git时,没有安装,而是在InstallApps文件夹中创建了一个localhost.mof文件:

Mode                LastWriteTime     Length Name                                                                      
----                -------------     ------ ----                                                                      
-a---        05-02-2016     11:35       1292 localhost.mof                                                             

[Finished in 2.4s]

为什么不触发安装?

我没有读过你引用的博客,但是运行上面的函数只会创建 mof 文件。

若要运行 mof 文件并执行所需的状态,需要运行 Start-DscConfiguration cmdlet。像下面这样...

Start-DscConfiguration -ComputerName TargetMachine -Path GeneratedMofFileLocation -Wait -Verbose

最新更新