VirtualEngine / Lability

Virtual Engine test lab deployment and configuration module
MIT License
283 stars 50 forks source link

Machine stuck at boot after successful DSC configuration. #374

Closed OsaPL closed 5 years ago

OsaPL commented 5 years ago

Ok, so after I use my Start script my machine looks like it is correctly configured by DSC, Get-DscConfigurationStatus returns Push as Successful, I cant see any Failed jobs in Get-WinEvents. I do all these checks by getting into cmd by Shift+F10 on booting screen. Unfortunately, it always requires a Reset/Reboot in Hyper-V Manager to be actually working, cause its stuck on HyperV logo with swirling dots.

Am I missing something with xPendingReboot module?

Included zip archive with ResourceData and scripts used. Resources.zip

iainbrighton commented 5 years ago

Hi @OsaPL - this normally means there is a problem with the configuration applied to the virtual machine. After resetting your VM and logging in, have a look at the C:\Bootstrap\Bootstrap-<date>-<time>.log file. This will probably tell you what is wrong. If it doesn't help, can you provide the contents of this file?

OsaPL commented 5 years ago

Hi @iainbrighton, thanks for the fast reply! These errors don't tell me that much, unfortunately.

Here is the log. Bootstrap-20190723-090609.log

Edit: WinRM on host is running.

iainbrighton commented 5 years ago

@OsaPL - I think I know what's going on. Can you post the contents of the C:\Bootstrap\Bootstrap.ps1 file? By default, on client OSes (server OSes are unaffected) PS remoting is disabled. In the bundled media, there is a custom bootstrap to enable this which is probably missing from your custom media definition...

OsaPL commented 5 years ago

Yeah, I was just testing that, Enter-PSSession -ComputerName localhost fails connecting on GuestOs.

BootStrap.txt

iainbrighton commented 5 years ago

I think this might work for you. I've added ImageName and CustomData properties (but you might not need the ImageName property or to enable the Administrator account in your custom bootstrap):

@{
AllNodes = @(
@{
NodeName = 'ApiTry3-192.168.15.113_CLIENT';
Role = 'CLIENT';
InterfaceAlias = 'Ethernet';
AddressFamily = 'IPv4';
IPAddress = '192.168.15.113/16';
Lability_SwitchName = 'Default Switch';
Lability_Media = 'Windows10Enterprise1903';
Lability_ProcessorCount = 2;
Lability_StartupMemory = 4294967296;
PSDscAllowPlainTextPassword = $true;
}
);
NonNodeData = @{
Lability = @{
DSCResource = @(
@{
Name = 'xComputerManagement';
RequiredVersion = '4.1.0.0';
}
@{
Name = 'xNetworking';
RequiredVersion = '5.7.0.0';
}
@{
Name = 'xRemoteDesktopAdmin';
RequiredVersion = '1.1.0.0';
}
);
Media = @(
@{
Id = 'Windows10Enterprise1903';
Filename = 'WIN10_x64_ENT_19H1_EN_Eval.iso';
Architecture = 'x64';
Uri = 'file://C:\Lability\ISOs\en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso';
Checksum = '';
Description = 'Windows 10 Enterprise';
ImageName = '1';
MediaType = 'ISO';
OperatingSystem = 'Windows';
CustomData = @{
  CustomBootstrap = @(
    '## Unattend.xml will set the Administrator password, but it wont enable the account on client OSes'
    'NET USER Administrator /active:yes;'
    'Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell -Name ExecutionPolicy -Value RemoteSigned -Force; #306'
    '## Kick-start PowerShell remoting on clients to permit applying DSC configurations'
    'Enable-PSRemoting -SkipNetworkProfileCheck -Force'
  )
}
}
@{
Id = 'Windows10Pro1903';
Filename = 'en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso';
Architecture = 'x64';
Uri = 'file://C:\Lability\ISOs\en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso';
Checksum = '';
Description = 'Windows 10 Pro';
MediaType = 'ISO';
OperatingSystem = 'Windows';
}
);
};
};
};
OsaPL commented 5 years ago

Log still looks the same, PsRemoting is still off.

Bootstrap-20190723-110148.log

Edit: Bootstrap.ps1 is exactly the same apparently.

iainbrighton commented 5 years ago

Certainly looks like a WinRM issue. Can you run winrm quickconfig in that VM and then trying running the Bootstrap.ps1 file again?

iainbrighton commented 5 years ago

Ah - the bootstrap should certainly be updated with the contents of the CustomBootstrap properties. Did you remove and recreate the VM?

OsaPL commented 5 years ago

Yeah. Shouldnt I recreate the custom media also?

iainbrighton commented 5 years ago

No - the custom bootstrap is copied in when the VM is created (it's not stored in the master VHDX file)

OsaPL commented 5 years ago

My cfgdata now looks like this:

@{
    AllNodes = @(
        @{
            ##Node name to distinguish the virtual machine
            NodeName                    = 'CLIENT2';
            ##Its role/designed state
            Role                        = 'CLIENT';
            InterfaceAlias              = 'Ethernet';
            AddressFamily               = 'IPv4';
            IPAddress                   = '192.168.15.110/16';
            ## Here we should have our virtual switch defined (probably the one we create with docker network)
            Lability_SwitchName         = 'b7a02214c394896d89bee662c3f2221a973f7d9c7162c6723a4a83a45e13892d';
            Lability_Media              = 'Windows10Enterprise1903';
            Lability_ProcessorCount     = 2;
            Lability_StartupMemory      = 4GB;
            PSDscAllowPlainTextPassword = $true;
        }
    );
    NonNodeData = @{
        Lability = @{
            DSCResource = @(
                @{ Name = 'xComputerManagement'; RequiredVersion = '4.1.0.0'; }
                @{ Name = 'xNetworking'; RequiredVersion = '5.7.0.0'; }
                @{ Name = 'xRemoteDesktopAdmin'; RequiredVersion = '1.1.0.0'; }
            );
            ##Custom Media list
            Media = @(
                @{
                    ## This example defines volume license edition of Server 2012 R2 ISO. NOTE: you will need to update
                    ## the Uri to point to a valid/accessible Uri location!
                    Id = 'Windows10Enterprise1903';
                    Filename = 'en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso';
                    Architecture = 'x64';
                    Uri = 'file://C:\Lability\ISOs\en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso';
                    Checksum = '';
                    Description = 'Windows 10 Enterprise';
                    MediaType = 'ISO';
                    ## ISO media requires the WIM image name/number to determine which image to extract
                    #ImageName = 'Windows 10 Enterprise';
                    ImageName = '1';
                    OperatingSystem = 'Windows';
                    CustomData = @{
                      CustomBootstrap = @(
                        '## Unattend.xml will set the Administrator password, but it wont enable the account on client OSes'
                        'NET USER Administrator /active:yes;'
                        'Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell -Name ExecutionPolicy -Value RemoteSigned -Force; #306'
                        '## Kick-start PowerShell remoting on clients to permit applying DSC configurations'
                        'Enable-PSRemoting -SkipNetworkProfileCheck -Force'
                      )
                    }
                },
                @{
                    Id = 'Windows10Pro1903';
                    Filename = 'en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso';
                    Architecture = 'x64';
                    Uri = 'file://C:\Lability\ISOs\en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso';
                    Checksum = '';
                    Description = 'Windows 10 Pro';
                    MediaType = 'ISO';
                    ImageName = 'Windows 10 Pro';
                    OperatingSystem = 'Windows';
                }
            );
        };
    };
};
OsaPL commented 5 years ago

Finally, I found the issue, in the Media = @( section elements were seperated by , when they shouldn't be. after removing it, everything works great!

CustomBootstrap is being merged in Bootstrap.ps1 and executed correctly.

Thanks for the help @iainbrighton!