簡體   English   中英

Powershell腳本以靜默方式安裝Azure Service Fabric SDK,運行時和工具

[英]Powershell script to install Azure Service Fabric SDK, runtime and tools silently

我正在嘗試編寫腳本以將安裝的Azure Service Fabric SDK,運行時和工具下載到一些服務器中。

我的問題是, 此處提供的安裝程序是Web Installer,並且不支持靜默模式。

我在這里找到了一個可以解決此問題的人。 他的代碼:

# Install Service Fabric Runtime
Invoke-WebRequest "http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabric.6.0.232.9494.exe" -OutFile "C:\ServiceFabricRuntime.exe" -UseBasicParsing; \
Start-Process "C:\ServiceFabricRuntime.exe" -ArgumentList '/AcceptEULA', '/QUIET' -NoNewWindow -Wait; \
rm "C:\ServiceFabricRuntime.exe"

# Install Service Fabric SDK
Invoke-WebRequest "http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabricSDK.2.8.232.msi" -OutFile "C:\ServiceFabricSDK.msi" -UseBasicParsing; \
Start-Process "msiexec" -ArgumentList '/i', 'C:\ServiceFabricSDK.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait; \
rm "C:\ServiceFabricSDK.msi"

如您所見,他正在使用指向.msi安裝程序的直接鏈接(以及其他人在其他線程中所做的工作,例如 兩個答案)。

因此,我的問題是,如何獲得這些安裝程序的最新版本與msi的直接鏈接?

接下來的問題是,是否有一個通用鏈接可以自動下載這些工具的最新版本?

提前致謝。

我知道這並不是您所要求的,但是您可以使用Web Platform Installer Command Line來靜默安裝WebPI產品。 這個想法是下載WebPICMD並從cmd行運行Service Fabric SDK安裝。 powershell腳本如下所示:

Invoke-WebRequest "https://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi" -OutFile "C:\WebPlatformInstaller.msi" -UseBasicParsing;
Start-Process "msiexec" -ArgumentList '/i', 'C:\WebPlatformInstaller.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait; 
rm "C:\WebPlatformInstaller.msi"

WebPICMD.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEULA

產品MicrosoftAzure-ServiceFabric-CoreSDK將以MicrosoftAzure-ServiceFabric-CoreSDK方式安裝最新版本的Service Fabric SDKService Fabric Runtime

如果要安裝不同於WebPI運行:

WebPICMD.exe /List /ListOption:All

該命令將列出所有可用的產品,僅獲取產品的ID並運行install命令。

有關WebPICMD更多信息, WebPICMD 點擊這里

要補充上面的答案,如果WebPlatformCMD給您Windows的UAC同意窗口問題,則可以使用PSEXEC工具作為系統帳戶運行安裝程序,從而避免了該問題。

示例代碼:

 Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkId=287166" -OutFile "$env:temp\WebPlatformInstaller_amd64_en-US.msi" -UseBasicParsing

 Start-Process "msiexec" -ArgumentList "/i $env:temp\WebPlatformInstaller_amd64_en-US.msi /passive /quiet /norestart /qn" -NoNewWindow -Wait

 $psToolsPath = "$env:temp\pstools"
 New-Item $psToolsPath -ItemType directory -force -erroraction silentlycontinue
 Invoke-WebRequest -Uri https://download.sysinternals.com/files/PSTools.zip -OutFile $psToolsPath\PSTools.zip

 Expand-Archive "$psToolsPath\PSTools.zip" $psToolsPath -force
 cd $psToolsPath
 Start-Process psexec64 -ArgumentList "-s /accepteula WebPICMD.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEULA"

關於上述SteppingRazor答案的小注釋。

您可以像這樣簡化ArgumentList參數值:

Start-Process "msiexec" -ArgumentList "/i C:\WebPlatformInstaller.msi /passive /quiet /norestart /qn -NoNewWindow -Wait

代替

Start-Process "msiexec" -ArgumentList '/i', 'C:\WebPlatformInstaller.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait;

然后在字符串中使用變量也更容易。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM