Powershell DSC:如何下载和安装 MSI
Powershell DSC: How to download and install MSI
如何使用 Powershell DSC 下载和安装 msi。我到目前为止看到的参考文献 link https://blogs.msdn.microsoft.com/brian_farnhill/2015/03/15/using-dsc-to-download-from-azure-file-storage-to-an-azure-vm/。但是我只能用于没有到http的共享文件夹。
File DownloadWebPi
{
DestinationPath = $PSScriptRoot
Ensure ="Present"
SourcePath = "http://go.microsoft.com/fwlink/?LinkId=287166"
Type = "File"
}
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
}
}
然后接下来写下一部分安装msi,这取决于这部分。
也不要使用 $PSScriptRoot
因为我相信它在 system32 中执行。
如何使用 Powershell DSC 下载和安装 msi。我到目前为止看到的参考文献 link https://blogs.msdn.microsoft.com/brian_farnhill/2015/03/15/using-dsc-to-download-from-azure-file-storage-to-an-azure-vm/。但是我只能用于没有到http的共享文件夹。
File DownloadWebPi
{
DestinationPath = $PSScriptRoot
Ensure ="Present"
SourcePath = "http://go.microsoft.com/fwlink/?LinkId=287166"
Type = "File"
}
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
}
}
然后接下来写下一部分安装msi,这取决于这部分。
也不要使用 $PSScriptRoot
因为我相信它在 system32 中执行。