PowerShell 安装virtio-win和 cloudinit

#下载安装Guest Agent 和 VSS Provider
wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win-gt-x64.msi" -O C:\virtio-win-gt-x64.msi
wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win-guest-tools.exe" -O C:\virtio-win-guest-tools.exe
Start-Process "C:\virtio-win-guest-tools.exe" -ArgumentList "/S"
Start-Process msiexec.exe -ArgumentList '/i "C:\virtio-win-gt-x64.msi" /quiet /norestart' -Wait

#下载安装 CloudInit
wget "https://github.com/cloudbase/cloudbase-init/releases/download/1.1.6/CloudbaseInitSetup_1_1_6_x64.msi"-O "C:\CloudbaseInitSetup.msi"
Start-Process msiexec.exe -ArgumentList '/i "C:\CloudbaseInitSetup.msi" /quiet /norestart' -Wait

#下载安装 CloudInit配置文件
wget "https://raw.githubusercontent.com/thundervm/proxmox-windows-template/refs/heads/main/conf/cloudbase-init-unattend.conf" -O "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\cloudbase-init-unattend.conf"
wget "https://raw.githubusercontent.com/thundervm/proxmox-windows-template/refs/heads/main/conf/cloudbase-init.conf" -O "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\cloudbase-init.conf"
wget "https://raw.githubusercontent.com/thundervm/proxmox-windows-template/refs/heads/main/conf/Unattend.xml" -O "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\Unattend.xml"

#设置virtio QEMU 的服务
cmd /c  sc config "QEMU-GA" start=auto
cmd /c sc config "QEMU Guest Agent VSS Provider" start=auto
cmd /c net start "QEMU Guest Agent VSS Provider"
cmd /c net start "QEMU-GA"

#下载初始化windows的脚本 默认不启用
wget  http://dl.kvm.la/windows/win11.txt -O  C:\script.bat
#cmd /c "C:\script.bat"

#执行sysprep初始化
C:\Windows\System32\sysprep\sysprep.exe /generalize /oobe /unattend:"C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\Unattend.xml"


#清除下载文件
rm C:\virtio-win-guest-tools.exe
rm  C:\virtio-win-gt-x64.msi
rm  C:\CloudbaseInitSetup.msi

添加新评论 »