在哪里可以找到最新的 unattended.xml 模式(xsd)?

在哪里可以找到最新的 unattended.xml 模式(xsd)?

我正在使用 Windows Server 2012、Windows 部署服务 (WDS) 和 Windows 评估和部署工具包 (ADK)。我创建了一个基本的 unattended.xml 文件。当我使用 xml 编辑器进行编辑时,实际上有点烦人,因为我没有 xsd。

基本上,我想知道 unattended.xml 文件是否有架构 (xsd)。我知道我可以轻松转到Microsoft TechNet:无人参与的 Windows 安装程序网站,但我发现有两个问题:

  1. 我似乎找不到每个节点可用的属性。

    例如...我知道Microsoft-Windows-安装程序允许诸如publicKeyToken、、、和之language类的属性,只需查看我拥有的默认 unattended.xml 文件即可;但是,在页面上我没有看到列出的这些属性......只有摘要以及可以放置在此节点内的节点。versionScopeprocessorArchitecture

  2. 它不会提高速度,也不会让我在 xml 编辑器中编辑 xml 文件变得更容易。

再次,只是寻找我可以实际找到 xsd 的地方,无论它是 Microsoft 下载,还是位于 Microsoft 下载的特定文件夹位置,或者如果它必须是手工制作的,甚至是某人的天空驱动器帐户。

答案1

根据这个 stackoverflow 问题(关联),您可以生成它

xsd.exe unattend.xml

我对 MDT 中的所有 xsd 文件进行了一些关键字搜索,文件匹配如下publicKeyToken,,languageprocessorArchitecture(但没有versionScope

C:\Program Files\Microsoft Deployment Toolkit\Templates\Packages.xsd

似乎我已经陷入了死胡同,即使从 MS 文档来看也是如此。http://schemas.microsoft.com/unattend给出错误页面(它确实包含其他 MS 架构)。尝试在某些 DLL 上使用资源查看器,但没有找到任何 xsd 资源。我开始怀疑无人值守架构作为某种数据结构存储在 MS 工具中。

我确实使用了xsd.exeagainstMicrosoft Deployment Toolkit\Templates\Unattend_Core_x64.xml并生成了以下 xsd。也许这可以帮助您的 xml 编辑器。(这不能替代官方架构。)

无人值守_Core_x64.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="unattend" targetNamespace="urn:schemas-microsoft-com:unattend" xmlns:mstns="urn:schemas-microsoft-com:unattend" xmlns="urn:schemas-microsoft-com:unattend" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:app1="http://schemas.microsoft.com/WMIConfig/2002/State">
  <xs:import namespace="http://schemas.microsoft.com/WMIConfig/2002/State" schemaLocation="Unattend_Core_x64_app1.xsd" />
  <xs:element name="unattend" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="settings">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="component" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="ComputerName" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
                    <xs:element name="ProductKey" type="xs:string" minOccurs="0" msdata:Ordinal="2" />
                    <xs:element name="RegisteredOrganization" type="xs:string" minOccurs="0" msdata:Ordinal="3" />
                    <xs:element name="RegisteredOwner" type="xs:string" minOccurs="0" msdata:Ordinal="4" />
                    <xs:element name="DoNotCleanTaskBar" type="xs:string" minOccurs="0" msdata:Ordinal="5" />
                    <xs:element name="TimeZone" type="xs:string" minOccurs="0" msdata:Ordinal="6" />
                    <xs:element name="InputLocale" type="xs:string" minOccurs="0" msdata:Ordinal="7" />
                    <xs:element name="SystemLocale" type="xs:string" minOccurs="0" msdata:Ordinal="8" />
                    <xs:element name="UILanguage" type="xs:string" minOccurs="0" msdata:Ordinal="9" />
                    <xs:element name="UserLocale" type="xs:string" minOccurs="0" msdata:Ordinal="10" />
                    <xs:element name="UserAccounts" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="AdministratorPassword" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="Value" type="xs:string" minOccurs="0" />
                                <xs:element name="PlainText" type="xs:string" minOccurs="0" />
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="AutoLogon" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Enabled" type="xs:string" minOccurs="0" />
                          <xs:element name="Username" type="xs:string" minOccurs="0" />
                          <xs:element name="Domain" type="xs:string" minOccurs="0" />
                          <xs:element name="LogonCount" type="xs:string" minOccurs="0" />
                          <xs:element name="Password" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="Value" type="xs:string" minOccurs="0" />
                                <xs:element name="PlainText" type="xs:string" minOccurs="0" />
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="RunSynchronous" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="RunSynchronousCommand" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="Description" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
                                <xs:element name="Order" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
                                <xs:element name="Path" type="xs:string" minOccurs="0" msdata:Ordinal="2" />
                              </xs:sequence>
                              <xs:attribute ref="app1:action" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="Identification" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="JoinDomain" type="xs:string" minOccurs="0" />
                          <xs:element name="JoinWorkgroup" type="xs:string" minOccurs="0" />
                          <xs:element name="MachineObjectOU" type="xs:string" minOccurs="0" />
                          <xs:element name="Credentials" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="Username" type="xs:string" minOccurs="0" />
                                <xs:element name="Domain" type="xs:string" minOccurs="0" />
                                <xs:element name="Password" type="xs:string" minOccurs="0" />
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="SetupUILanguage" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="UILanguage" type="xs:string" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="ImageInstall" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="OSImage" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="WillShowUI" type="xs:string" minOccurs="0" />
                                <xs:element name="InstallTo" minOccurs="0" maxOccurs="unbounded">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="DiskID" type="xs:string" minOccurs="0" />
                                      <xs:element name="PartitionID" type="xs:string" minOccurs="0" />
                                    </xs:sequence>
                                  </xs:complexType>
                                </xs:element>
                                <xs:element name="InstallFrom" minOccurs="0" maxOccurs="unbounded">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="Path" type="xs:string" minOccurs="0" />
                                      <xs:element name="MetaData" minOccurs="0" maxOccurs="unbounded">
                                        <xs:complexType>
                                          <xs:sequence>
                                            <xs:element name="Key" type="xs:string" minOccurs="0" />
                                            <xs:element name="Value" type="xs:string" minOccurs="0" />
                                          </xs:sequence>
                                        </xs:complexType>
                                      </xs:element>
                                    </xs:sequence>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="Display" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="ColorDepth" type="xs:string" minOccurs="0" />
                          <xs:element name="HorizontalResolution" type="xs:string" minOccurs="0" />
                          <xs:element name="RefreshRate" type="xs:string" minOccurs="0" />
                          <xs:element name="VerticalResolution" type="xs:string" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="FirstLogonCommands" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="SynchronousCommand" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="CommandLine" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
                                <xs:element name="Description" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
                                <xs:element name="Order" type="xs:string" minOccurs="0" msdata:Ordinal="2" />
                              </xs:sequence>
                              <xs:attribute ref="app1:action" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="OOBE" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="HideEULAPage" type="xs:string" minOccurs="0" />
                          <xs:element name="NetworkLocation" type="xs:string" minOccurs="0" />
                          <xs:element name="ProtectYourPC" type="xs:string" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="ComplianceCheck" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="DisplayReport" type="xs:string" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="UserData" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="AcceptEula" type="xs:string" minOccurs="0" />
                          <xs:element name="ProductKey" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="Key" type="xs:string" minOccurs="0" />
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="DriverPaths" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="PathAndCredentials" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="Path" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
                              </xs:sequence>
                              <xs:attribute ref="app1:keyValue" />
                              <xs:attribute ref="app1:action" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="name" form="unqualified" type="xs:string" />
                  <xs:attribute name="processorArchitecture" form="unqualified" type="xs:string" />
                  <xs:attribute name="publicKeyToken" form="unqualified" type="xs:string" />
                  <xs:attribute name="language" form="unqualified" type="xs:string" />
                  <xs:attribute name="versionScope" form="unqualified" type="xs:string" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="pass" form="unqualified" type="xs:string" />
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

答案2

有一个用于验证的 powershell 脚本:

https://gist.github.com/davidwallis3101/48454cb6c17c988de43b5ea17089ea6f

在其中,我找到了有关模式的位置以及如何在以下 URL 中提取模式的描述:

https://schneegans.de/windows/unattend-schema/

它是在 ADK 的某些组件中经过 base64 编码的:

文件名为microsoft.componentstudio.componentplatforminterface.dll,资源路径为: Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources

由于它只是名为 MyResources,我猜想它是在时间压力下构建的,也许这就是为什么没有人有机会发布它。我想它需要有人在 Microsoft 有好朋友才能以更易于访问的方式发布它。

答案3

基于(在发现这个答案,我创建了以下 PowerShell 脚本。我必须更新命令中的某些路径ildasm(例如,所有文件都位于该文件夹中${env:ProgramFiles(x86)},或者microsoft.componentstudio.componentplatforminterface.dll文件现在已移至架构文件夹中。

# Extract unattend XSD from Windows ADK


# Define where the XSD schema should be saved, incl the filename
$out = "$env:USERPROFILE\unattend_win_10.xsd"

# Download Windows ADK 10.1.25398.1
Write-Output 'Downloading Windows ADK ...'

$adksetup = Start-BitsTransfer 'https://go.microsoft.com/fwlink/?linkid=2243390' -Destination "$env:TEMP/adksetup.exe"

switch ($adksetup.JobState) {
  'Transferred' {
    Complete-BitsTransfer -BitsJob $adksetup
    Write-Output 'Windows ADK downloaded.'
    break
  }

  'Error' {
    throw 'Error downloading Windows ADK.'
  }
}

# Download .NET Framework 4.7.2 Developer Pack
Write-Output 'Downloading .NET Framework 4.7.2 Developer Pack ...'

$dotnet = Start-BitsTransfer 'https://go.microsoft.com/fwlink/?linkid=2243390' -Destination "$env:TEMP/dotnet_4.7.2_dev_pack.exe"

switch ($dotnet.JobState) {
  'Transferred' {
    Complete-BitsTransfer -BitsJob $dotnet
    Write-Output '.NET Framework 4.7.2 Developer Pack downloaded.'
    break
  }

  'Error' {
    throw 'Error downloading .NET Framework 4.7.2 Developer Pack.'
  }
}

# Install Deployment Tools feature from Windows ADK
Write-Output 'Installing Windows ADK ...'
Start-Process -Wait "$env:TEMP\adksetup.exe" -ArgumentList '/q /features OptionId.DeploymentTools /norestart /ceip off'
Write-Output 'Windows ADK installed.'

# Install .NET Framework 4.7.2 Developer Pack
Write-Output 'Installing .NET Framework 4.7.2 Developer Pack ...'
Start-Process -Wait "$env:TEMP\dotnet_4.7.2_dev_pack.exe"
Write-Output '.NET Framework 4.7.2 Developer Pack installed.'

if (!(Test-Path "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\ildasm.exe" -PathType Leaf)) {
  throw 'Could not find `ildasm.exe`.'
}

if (!(Test-Path "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\WSIM\amd64\microsoft.componentstudio.componentplatforminterface.dll" -PathType Leaf)) {
  throw 'Could not find `microsoft.componentstudio.componentplatforminterface.dll`.'
}

# Extract the resources embedded in `microsoft.componentstudio.componentplatforminterface.dll`
Write-Output 'Extracting the XSD schema embedded in `microsoft.componentstudio.componentplatforminterface.dll`'
& "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\ildasm.exe" "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\WSIM\amd64\microsoft.componentstudio.componentplatforminterface.dll" /Output="$env:TEMP\out.il"

if (!(Test-Path "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources" -PathType Leaf)) {
  throw 'Could not find `Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources`.'
}

# Get content from the input file
$fileContent = Get-Content -Path "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources" -Raw

# Regular expression (Regex) of the given start and end patterns
$pattern = '(?is)({0}.*?{1})' -f [regex]::Escape('<?xml version='), [regex]::Escape('</xsd:schema>')

# Perform the Regex operation and save it to file
[regex]::Match($fileContent, $pattern).Groups[1].Value | Set-Content -Path "$out"

if (!(Test-Path "$out" -PathType Leaf)) {
  throw "Could not find `$out`."
}

Write-Output 'The XSD schema extracted.'

# Clean up
Remove-Item "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.DistributionShareResources.resources", "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources", "$env:TEMP\adksetup.exe", "$env:TEMP\dotnet_4.7.2_dev_pack.exe", "$env:TEMP\out.il", "$env:TEMP\out.res"

答案4

如果您已安装 WAIK 8,请转到安装它的目录。找到文件 Microsoft.ComponentStudio.ComponentPlatformInterface.dll 并在您最喜欢的反编译器中打开它,看看 Microsoft 是如何做到的。

要查看的主要方法是方法Validate(),当您查看它时,它会经历不同的阶段(传递)并逐一验证它们。ValidateXml()很有用,值得一看,DoLoad()也是如此

它基本上是获取一些与 WAIK 一起安装的 XSD 文件并使用它们:
“C:\Program Files\Microsoft Deployment Toolkit\Templates\Drivers.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\Groups.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\InstallerComponents.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\LinkedDeploymentShares.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\Medias.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\OperatingSystems.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\Packages.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\SelectionProfiles.xsd”
“C:\Program Files\Microsoft Deployment Toolkit\Templates\TaskSequences.xsd“
“C:\Program Files\Microsoft Deployment Toolkit\Templates\Applications.xsd”

相关内容