WindowsImageTools icon indicating copy to clipboard operation
WindowsImageTools copied to clipboard

Reuse Use Case - Separate Unattended

Open drstonephd opened this issue 5 years ago • 3 comments

Once I get an set of disks built for a VM, I will want to copy them for each new VM. Because I do not have all the info (e.g., computer name and OU), perhaps the injection of the unattended file should be separate. Then the unattended can be applied to a copy of a VHDX. Are there other things that should be separate?

Also, from what I've read online, it appears that both x86 and amd64 sections for the some thing will both run on an amd64 system if both are present. The WinPE pass needs to be x86 or amd64, depending upon what WinPE is using. The other passes are only in the x86 or amd64 of the OS deployed? Can the WinPE and OS architectures be detected from the image?

Expected Behavior

The unattended file generated should have one section per architecture. The architecture of the section needs to be appropriate for both the WinPE and OS deployed. The unattended file will be specific to each deployment, so it needs to be applied (or re-applied) after the base image is copied.

Current Behavior

The unattended can have both or have x86 when deploying to amd64. If I copy the VHDX files for a new VM, I will need to create a new function to call New-UnattendedXMl and replace the existing unattended file. Or I will need to manually mount the VHDX and update the unattended file.

Possible Solution

Use only amd64 in the template. Change the attribute to x86 in WinPE pass components if WinPe is x86. Change the other components proc attribute to x86 is the OS is 32 bit. In those rare cases that the x86 and amd64 components for the same thing are different, then include both in the template and later remove any that do not apply.

The code should be x86 and amd64 agnostic unless there is a real difference in how the xml is constructed. The x86/amd64 attribute can be altered as needed for those that are otherwise identical.

Steps to Reproduce (for bugs)

Context

I'm testing with a windows server 2019 image. I changed all "x86" entries in the New-UnattendedXML template to "amd64" and removed duplicates. Then I updated the code to insure there was no duplicate processing or specific test for x86. Works for the amd64 only case.

Your Environment

  • Module version used:
  • Operating System and PowerShell version:

drstonephd avatar Jun 08 '19 13:06 drstonephd

In what case is having both architecture causing you an issue?

None of my testing has ever shown an bad side effect to having both.

BladeFireLight avatar Jun 09 '19 15:06 BladeFireLight

I think it's been working, but Microsoft warns about using both in the same file. (See the end of the documentation at the following link.) I do not know how this all works, but it if x86 works for both x86 and amd64, then why bother with defining a section for amd64?

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-7/dd799255%28v%3dws.10%29

I will try just x86. My attempt to add letters to the extra partitions was ignored. Probably because the drives are offline. I added a section to change the SAN policy that prevents them from coming online, but it was ignored. I used amd64, but the documentation indicated x86. Maybe that's the issue. If the oflineServicing pass is after the windowsPE pass, then perhaps this can't work. I have never tried this before. You're module inspired me to see if I can write a script to built a SQL Server unattended.

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <settings pass="offlineServicing">
    <component name="Microsoft-Windows-PartitionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
      <SanPolicy>1</SanPolicy>
    </component>
  </settings>
  <settings pass="windowsPE">
    <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral">
      <DiskConfiguration>
        <Disk wcm:action="add">
          <DiskID>0</DiskID>
          <ModifyPartitions>
            <ModifyPartition wcm:action="add">
              <Order>1</Order>
              <PartitionID>3</PartitionID>
              <Label>OS</Label>
              <Letter>C</Letter>
            </ModifyPartition>
          </ModifyPartitions>
        </Disk>
        <Disk wcm:action="add">
          <DiskID>1</DiskID>
          <ModifyPartitions>
            <ModifyPartition wcm:action="add">
              <Order>1</Order>
              <PartitionID>2</PartitionID>
              <Label>SQL</Label>
              <Letter>G</Letter>
            </ModifyPartition>
          </ModifyPartitions>
        </Disk>
        <Disk wcm:action="add">
          <DiskID>2</DiskID>
          <ModifyPartitions>
            <ModifyPartition wcm:action="add">
              <Order>1</Order>
              <PartitionID>2</PartitionID>
              <Label>BACKUP</Label>
              <Letter>H</Letter>
            </ModifyPartition>
          </ModifyPartitions>
        </Disk>
        <Disk wcm:action="add">
          <DiskID>3</DiskID>
          <ModifyPartitions>
            <ModifyPartition wcm:action="add">
              <Order>1</Order>
              <PartitionID>2</PartitionID>
              <Label>DATA</Label>
              <Letter>I</Letter>
            </ModifyPartition>
          </ModifyPartitions>
        </Disk>
        <Disk wcm:action="add">
          <DiskID>4</DiskID>
          <ModifyPartitions>
            <ModifyPartition wcm:action="add">
              <Order>1</Order>
              <PartitionID>2</PartitionID>
              <Label>LOG</Label>
              <Letter>J</Letter>
            </ModifyPartition>
          </ModifyPartitions>
        </Disk>
        <Disk wcm:action="add">
          <DiskID>5</DiskID>
          <ModifyPartitions>
            <ModifyPartition wcm:action="add">
              <Order>1</Order>
              <PartitionID>2</PartitionID>
              <Label>TEMPDB</Label>
              <Letter>T</Letter>
            </ModifyPartition>
          </ModifyPartitions>
        </Disk>
      </DiskConfiguration>
    </component>
  </settings>
etc.

Also, here is a link to the SAN policy bit.

https://support.microsoft.com/en-us/help/973834/microsoft-hyper-v-server-san-policy-is-set-to-automatically-mount-volu

drstonephd avatar Jun 09 '19 16:06 drstonephd

I changed the san policy and disk config components to x86 and they are still ignored. I might end up using Set-Disk and Set-Partition to bring them online and set the label and letter.

drstonephd avatar Jun 09 '19 20:06 drstonephd