VMware Workstation 前言
VMware Workstation Pro 是业界标准的桌面 Hypervisor,用于在 Linux 或 Windows PC 上运行虚拟机
download VMware_Workstation
VMware_Workstation Windows | VMware_Workstation linux | 文档 |
download | download | 参考 |
前提条件
- 开启wmi,配置网卡,参考
- 默认服务器CPU虚拟化功能开启的,PC需要人工干预开启CPU虚拟化功能
创建已经部署VMware_Workstation
- 实现在线下载VMware_Workstation,安装,环境变量,开机启动VMware_Workstation,剪切安装包安装目录用于后期卸载VMware_Workstation,企业微信机器人通知。
- $webhook #更改自己的企业微信机器人地址
- SERIALNUMBER #VMware_Workstation key
- INSTALLDIR #需要安装的位置目录名称
- Start-Process -FilePath $drive\$vmware_workstation_exe -ArgumentList {/s /v /qn EULAS_AGREED=1 SERIALNUMBER="JU090-6039P-08409-8J0QH-2YR7F" AUTOSOFTWAREUPDATE=1 REBOOT=ReallySuppress} -Wait #默认不指定目录安装方式
- Start-Process -FilePath $drive\$vmware_workstation_directory_new\$vmware_workstation_exe -ArgumentList {/s /v /qn REMOVE=ALL} -Wait #卸载VMware_Workstation
- 安装位置在c:\vmware_workstation #根据自己的业务需求定义名称
powershell-install-VMware_Workstation.ps1
<# Powershell Install VMware Workstation
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+ _____ _____ _ _ _ +
+ | __ \ / ____| | | | |+
+ | |__) |____ _____ _ _| (___ | |__ ___| | |+
+ | ___/ _ \ \ /\ / / _ \ '__\___ \| '_ \ / _ \ | |+
+ | | | (_) \ V V / __/ | ____) | | | | __/ | |+
+ |_| \___/ \_/\_/ \___|_| |_____/|_| |_|\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++
install VMware_Workstation
https://docs.vmware.com/en/VMware-Workstation-Pro/16.0/workstation-pro-16-user-guide.pdf
downlad VMware_Workstation
https://download3.vmware.com/software/WKST-1700-WIN/VMware-workstation-full-17.0.0-20800274.exe
# Powershell Install VMware Workstation
# .\powershell-install-VMware_Workstation.ps1
#>
$drive="c:"
$vmware_workstation_url="https://download3.vmware.com/software/WKST-1700-WIN/"
$vmware_workstation_exe="VMware-workstation-full-17.0.0-20800274.exe"
$vmware_workstation_directory_new="vmware_workstation"
Write-Host "download VMware Workstation" -ForegroundColor Green
Invoke-WebRequest -Uri $vmware_workstation_url\$vmware_workstation_exe -UseBasicParsing -OutFile $drive\$vmware_workstation_exe
Write-Host "Specify different directory installation methods install vmware_workstation" -ForegroundColor Green
Start-Process -FilePath $drive\$vmware_workstation_exe -ArgumentList {/s /v /qn EULAS_AGREED=1 INSTALLDIR="c:\vmware_workstation" SERIALNUMBER="JU090-6039P-08409-8J0QH-2YR7F" AUTOSOFTWAREUPDATE=1 REBOOT=ReallySuppress} -Wait
Write-Host "Create VMware Workstation environment variables" -ForegroundColor Green
$env:path += ";$drive\$vmware_workstation_directory_new"
setx PATH $env:path /M
Write-Host "start VMware Workstation" -ForegroundColor Green
Start-Process -FilePath "vmware.exe"
Write-Host "bootstrap vmware_desktop" -ForegroundColor Green
Start-Process schtasks {/create /tn vmware_desktop /tr c:\vmware_workstation\vmware.exe /sc ONLOGON} -Verb runas
#It is used for later software uninstallation
Write-Host "Cut the installation package to the directory" -ForegroundColor Green
Move-Item -Path "$drive\$vmware_workstation_exe" -Destination "$drive\$vmware_workstation_directory_new"
#Enterprise wechat robot address
$webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXX"
#Obtain the Windows host system version
$Win_version = Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Caption
$Win_version_Names = echo $Win_version
#vmware_workstation version
$vmware_workstation_version = (Get-Item "$drive\$vmware_workstation_directory_new\vmware.exe").VersionInfo.FileVersion
$content = Write-Output ""Win_version: $Win_version_Names" `n "vmware_workstation_version: $vmware_workstation_version""
$body = "{
`"msgtype`":`"text`",
`"text`":{
`"content`":`"$content`",
`"mentioned_list`":[`"jason`"]
}
}"
Write-Host "The variable value obtained is transferred to the enterprise wechat robot" -ForegroundColor Green
Invoke-RestMethod $webhook -ContentType "application/json;charset=utf-8" -Method Post -Body $body
执行安装
.\powershell-install-VMware_Workstation.ps1
输出结果展示
企业微信机器人通知
powershell 直接打开VMware_Workstation
- 自动化脚本已经配置VMware系统的环境变量
- C:\vmware_workstation\vmware.exe #完整的路径
vmware.exe