繁体   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