Enable-VMIntegrationService cmdlet has a language dependent value for -Name option. So avoid using it, as it will break on machines with different languages.
This commit is contained in:
parent
9c53df1e0e
commit
7ce9203530
|
@ -472,13 +472,31 @@ if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Running) {
|
|||
|
||||
func EnableVirtualMachineIntegrationService(vmName string, integrationServiceName string) error {
|
||||
|
||||
integrationServiceId := ""
|
||||
switch integrationServiceName {
|
||||
case "Time Synchronization":
|
||||
integrationServiceId = "2497F4DE-E9FA-4204-80E4-4B75C46419C0"
|
||||
case "Heartbeat":
|
||||
integrationServiceId = "84EAAE65-2F2E-45F5-9BB5-0E857DC8EB47"
|
||||
case "Key-Value Pair Exchange":
|
||||
integrationServiceId = "2A34B1C2-FD73-4043-8A5B-DD2159BC743F"
|
||||
case "Shutdown":
|
||||
integrationServiceId = "9F8233AC-BE49-4C79-8EE3-E7E1985B2077"
|
||||
case "VSS":
|
||||
integrationServiceId = "5CED1297-4598-4915-A5FC-AD21BB4D02A4"
|
||||
case "Guest Service Interface":
|
||||
integrationServiceId = "6C09BB55-D683-4DA0-8931-C9BF705F6480"
|
||||
default:
|
||||
panic("unrecognized Integration Service Name")
|
||||
}
|
||||
|
||||
var script = `
|
||||
param([string]$vmName,[string]$integrationServiceName)
|
||||
Enable-VMIntegrationService -VMName $vmName -Name $integrationServiceName
|
||||
param([string]$vmName,[string]$integrationServiceId)
|
||||
Get-VMIntegrationService -VmName $vmName | ?{$_.Id -match $integrationServiceId} | Enable-VMIntegrationService
|
||||
`
|
||||
|
||||
var ps powershell.PowerShellCmd
|
||||
err := ps.Run(script, vmName, integrationServiceName)
|
||||
err := ps.Run(script, vmName, integrationServiceId)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue