azure - 如何使用自定义扩展脚本在虚拟机上安装软件
问题描述
我想使用自定义扩展脚本在虚拟机上安装软件(.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"
解决方案
根据我的研究,我们可以使用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
推荐阅读
- sorting - 根据另一个切片中的键对切片进行排序而不分配
- javascript - Javascript 3d数组问题
- android - Gradle:如何在 gradle 文件中使用外部 final 变量
- javascript - window.history.forward() 在 .cshtml 视图中不起作用
- javascript - 如何在redux状态javascript中从另一个数组中删除一个数组
- swift - 使用组合运算符将 Future 转换为 Publisher
- c++ - 无法在 CMake 中链接本地库
- javascript - 正则表达式排除匹配
- python - 模仿python中汉字的Web URL编码
- node.js - 处理多个确认提示