2016-02-05 72 views
1

我想使用DSC在Windows 7上安装的Git使用基于PowerShell的4.0:DSC不安装的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:\tmp\Git-2.7.0.2-64-bit.exe" 
     ProductId = '' 
    } 
    } 
} 
InstallApps 

Git是没有安装在那里我运行的机器上上面的脚本来自。

当我运行上面的git未安装而不是localhost.mof文件夹中创建InstallApps

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


[Finished in 2.4s] 

为什么安装不触发?

回答

1

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

为了运行mof文件并执行所需的状态,您需要运行Start-DscConfiguration cmdlet。类似以下内容...

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