首页 > 解决方案 > 如何使用自定义扩展脚本在虚拟机上安装软件

问题描述

我想使用自定义扩展脚本在虚拟机上安装软件(.msi 文件)。

下面是我的 powershell 自定义扩展脚本。

$computername = 'testingpurpose'
$sourcefile = "//fossies.org/windows/misc/mysql-workbench-community-8.0.18-winx64.msi"
$destinationFolder = "\\$computername\C$\Temp"

Copy-Item -Path $sourcefile -Destination $destinationFolder 

Invoke-Command -ComputerName $computername -ScriptBlock { Msiexec /i //fossies.org/windows/misc/mysql-workbench-community-8.0.18-winx64.msi /log C:\MSIInstall.log }
                          (or)
Start-Process -destinationFolder //fossies.org/windows/misc/mysql-workbench-community-8.0.18-winx64.msi -ArgumentList '/i',$destinationFolder,'/q' -Wait -PassThru -Verb "RunAs"

标签: azurevirtual-machineazure-powershell

解决方案


根据我的研究,我们可以使用choco在 windows Vm 上安装 mysql-workbench。更多详情,请参阅博客

我的脚本如下

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
choco install mysql.workbench

推荐阅读