Powershell DSC:如何下载和安装MSI

时间:2017-06-09 09:12:39

标签: powershell dsc

使用Powershell DSC如何下载和安装msi。我到目前为止看到的链接https://blogs.msdn.microsoft.com/brian_farnhill/2015/03/15/using-dsc-to-download-from-azure-file-storage-to-an-azure-vm/。但我只能用于共享文件夹no到http。

        File DownloadWebPi
        {
            DestinationPath = $PSScriptRoot
            Ensure ="Present"
            SourcePath = "http://go.microsoft.com/fwlink/?LinkId=287166"
            Type = "File"
        }

1 个答案:

答案 0 :(得分:0)

Script DownloadMsi
{
            GetScript = 
            {
                @{
                    GetScript = $GetScript
                    SetScript = $SetScript
                    TestScript = $TestScript
                    Result = ('True' -in (Test-Path c:\Somepath\install.msi))
                }
            }

            SetScript = 
            {
                Invoke-WebRequest -Uri "http://go.microsoft.com/fwlink/?LinkId=287166" -OutFile "c:\Somepath\install.msi"
            }

            TestScript = 
            {
                $Status = ('True' -in (Test-Path c:\Somepath\install.msi))
                $Status -eq $True
            }
        }

And then next write next part to install msi which depends on this section. Also don't use $PSScriptRoot as I believe this executes in system32.