Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not retrieve VM runtime logs #352

Open
oott123 opened this issue Nov 23, 2020 · 2 comments
Open

Could not retrieve VM runtime logs #352

oott123 opened this issue Nov 23, 2020 · 2 comments

Comments

@oott123
Copy link

oott123 commented Nov 23, 2020

The code here is using Get-VMIntegrationService $Name -Name "Key-Value Pair Exchange").Enabled to check if KV pair exchange service is enabled.

However, when you are using a non-English locale of Windows, you will get other names like 键值对交换 (in chinese):

image

And it throws a error when getting by name:

# Get-VMIntegrationService WindowsOnlineImage-Sysprep354251398 -Name "Key-Value Pair Exchange"
Get-VMIntegrationService : 找不到具有给定名称的集成组件。
所在位置 行:1 字符: 1
+ Get-VMIntegrationService WindowsOnlineImage-Sysprep354251398 -Name "K ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-VMIntegrationService],VirtualizationException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVMIntegrationService

which will cause "Could not retrieve VM runtime logs"

So I think we should remove the integration service enabled check in order to retrive the log correctly:

--- a/WinImageBuilder.psm1
+++ b/WinImageBuilder.psm1
@@ -1158,8 +1158,7 @@ function Wait-ForVMShutdown {
         $vmState = (Get-VM -Name $Name).State
         $isOff =  $vmState -eq "Off"
         try {
-            if ($vmState -ne "Running" -or `
-                !(Get-VMIntegrationService $Name -Name "Key-Value Pair Exchange").Enabled) {
+            if ($vmState -ne "Running") {
                 continue
             }
             $currentVMMessages = Get-KVPData -VMName $Name
@MrEasy
Copy link

MrEasy commented Jun 23, 2022

can confirm the same issue when buildong on a German Win11.
Your change resolves it.

MrEasy added a commit to MrEasy/windows-imaging-tools that referenced this issue Jul 6, 2022
@tatsushid
Copy link

If it needs to keep the integration service check, it can be done like the following I think

--- a/WinImageBuilder.psm1
+++ b/WinImageBuilder.psm1
@@ -1195,7 +1197,7 @@ function Wait-ForVMShutdown {
         $isOff =  $vmState -eq "Off"
         try {
             if ($vmState -ne "Running" -or `
-                !(Get-VMIntegrationService $Name -Name "Key-Value Pair Exchange").Enabled) {
+                !(Get-VMIntegrationService $Name | Where-Object Id -Match "2A34B1C2-FD73-4043-8A5B-DD2159BC743F").Enabled) {
                 continue
             }
             $currentVMMessages = Get-KVPData -VMName $Name

The ID value is described at MicrosoftDocs/azure-docs#52634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants