启动前将 MOF 文件复制到 vhd (xvhdFile)
copying MOF file to vhd (xvhdFile) before boot
我正在单个服务器上构建实验室 DSC。我有一个服务器 (vhdx
) 的 mof 文件,我正在将其复制到 c:\windows\system32\configuraiton\pending.mof
。这个想法是在启动时,系统将应用 mof 并配置系统。
很遗憾,没有复制 mof 文件。我在 xVhdFile
下有其他条目正在被复制(unattended.xml
、DSC resource directories
),但不是 mof。有人知道为什么吗?
这是 xVhdFile
条目:
xVhdFile "CopyUnattendedXml DC01"
{
VhdPath = "F:\VMs\DC01\DC01`.vhdx"
FileDirectory = @(
# Pending.mof
MSFT_xFileDirectory {
SourcePath = 'F:\DSCScripts\Lab01\ForestRoot\Localhost.mof'
DestinationPath = "\Windows\Sytem32\Configuration\Pending.mof"
}
# unattend.xml
MSFT_xFileDirectory {
SourcePath = 'F:\VMs\Sysprep16DataCenterEval_2.xml'
DestinationPath = "\Windows\System32\Sysprep\Unattend.xml"
}
# xActiveDirectory
MSFT_xFileDirectory {
SourcePath = 'C:\Program Files\WindowsPowerShell\Modules\xActiveDirectory\'
DestinationPath = "\Program Files\WindowsPowerShell\Modules\"
type = 'Directory'
Recurse = $True
}
# xNetworking
MSFT_xFileDirectory {
SourcePath = 'C:\Program Files\WindowsPowerShell\Modules\xNetworking\'
DestinationPath = "\Program Files\WindowsPowerShell\Modules\"
type = 'Directory'
Recurse = $True
}
)
DependsOn = "[File]CopyBaseImage DC01"
}
谢谢
详细输出:
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ Start Resource ] [[xVhdFile]CopyUnattendedXml DC01]
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ Start Test ] [[xVhdFile]CopyUnattendedXml DC01]
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Alias
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] C
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Cert
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] D
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] E
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Env
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] F
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Function
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] H
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKCU
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKLM
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Variable
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] WSMan
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] H:\
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] DestinationPath => \Windows\Sytem32\Configuration\Pending.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Recurse => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Force => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Type => File
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Ensure => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Content =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] SourcePath => F:\DSCScripts\Lab01\ForestRoot\Localhost.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Attributes =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Testing the file with relative VHD destination
\Windows\Sytem32\Configuration\Pending.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Test returned False
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ End Test ] [[xVhdFile]CopyUnattendedXml DC01] in 2.4530 seconds.
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ Start Set ] [[xVhdFile]CopyUnattendedXml DC01]
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Alias
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] C
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Cert
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] D
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] E
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Env
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] F
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Function
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] H
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKCU
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKLM
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Variable
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] WSMan
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] DestinationPath => \Windows\Sytem32\Configuration\Pending.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Recurse => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Force => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Type => File
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Ensure => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Content =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] SourcePath => F:\DSCScripts\Lab01\ForestRoot\Localhost.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Attributes =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Setting the VHD file Copy
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ End Set ] [[xVhdFile]CopyUnattendedXml DC01] in 1.6880 seconds.
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ End Resource ] [[xVhdFile]CopyUnattendedXml DC01]
你打错了。 Sytem32
应该是 System32
。这一行:
DestinationPath = "\Windows\Sytem32\Configuration\Pending.mof"
变成:
DestinationPath = "\Windows\System32\Configuration\Pending.mof"
正在复制文件,但未在预期位置复制。
我通过重现您的失败并通过 Pending.mof (dir F:\pending.mof -Recurse
) 的配置搜索 VHD 更新找到了这个,发现该文件夹实际上不是 DSC 配置文件夹。
我正在单个服务器上构建实验室 DSC。我有一个服务器 (vhdx
) 的 mof 文件,我正在将其复制到 c:\windows\system32\configuraiton\pending.mof
。这个想法是在启动时,系统将应用 mof 并配置系统。
很遗憾,没有复制 mof 文件。我在 xVhdFile
下有其他条目正在被复制(unattended.xml
、DSC resource directories
),但不是 mof。有人知道为什么吗?
这是 xVhdFile
条目:
xVhdFile "CopyUnattendedXml DC01"
{
VhdPath = "F:\VMs\DC01\DC01`.vhdx"
FileDirectory = @(
# Pending.mof
MSFT_xFileDirectory {
SourcePath = 'F:\DSCScripts\Lab01\ForestRoot\Localhost.mof'
DestinationPath = "\Windows\Sytem32\Configuration\Pending.mof"
}
# unattend.xml
MSFT_xFileDirectory {
SourcePath = 'F:\VMs\Sysprep16DataCenterEval_2.xml'
DestinationPath = "\Windows\System32\Sysprep\Unattend.xml"
}
# xActiveDirectory
MSFT_xFileDirectory {
SourcePath = 'C:\Program Files\WindowsPowerShell\Modules\xActiveDirectory\'
DestinationPath = "\Program Files\WindowsPowerShell\Modules\"
type = 'Directory'
Recurse = $True
}
# xNetworking
MSFT_xFileDirectory {
SourcePath = 'C:\Program Files\WindowsPowerShell\Modules\xNetworking\'
DestinationPath = "\Program Files\WindowsPowerShell\Modules\"
type = 'Directory'
Recurse = $True
}
)
DependsOn = "[File]CopyBaseImage DC01"
}
谢谢
详细输出:
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ Start Resource ] [[xVhdFile]CopyUnattendedXml DC01]
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ Start Test ] [[xVhdFile]CopyUnattendedXml DC01]
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Alias
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] C
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Cert
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] D
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] E
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Env
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] F
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Function
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] H
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKCU
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKLM
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Variable
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] WSMan
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] H:\
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] DestinationPath => \Windows\Sytem32\Configuration\Pending.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Recurse => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Force => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Type => File
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Ensure => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Content =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] SourcePath => F:\DSCScripts\Lab01\ForestRoot\Localhost.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Attributes =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Testing the file with relative VHD destination
\Windows\Sytem32\Configuration\Pending.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Test returned False
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ End Test ] [[xVhdFile]CopyUnattendedXml DC01] in 2.4530 seconds.
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ Start Set ] [[xVhdFile]CopyUnattendedXml DC01]
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Alias
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] C
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Cert
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] D
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] E
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Env
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] F
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Function
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] H
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKCU
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] HKLM
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Variable
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] WSMan
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] DestinationPath => \Windows\Sytem32\Configuration\Pending.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Recurse => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Force => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Type => File
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Ensure => True
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Content =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] SourcePath => F:\DSCScripts\Lab01\ForestRoot\Localhost.mof
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Attributes =>
VERBOSE: [WIN-LBCPOR4PDR5]: [[xVhdFile]CopyUnattendedXml DC01] Setting the VHD file Copy
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ End Set ] [[xVhdFile]CopyUnattendedXml DC01] in 1.6880 seconds.
VERBOSE: [WIN-LBCPOR4PDR5]: LCM: [ End Resource ] [[xVhdFile]CopyUnattendedXml DC01]
你打错了。 Sytem32
应该是 System32
。这一行:
DestinationPath = "\Windows\Sytem32\Configuration\Pending.mof"
变成:
DestinationPath = "\Windows\System32\Configuration\Pending.mof"
正在复制文件,但未在预期位置复制。
我通过重现您的失败并通过 Pending.mof (dir F:\pending.mof -Recurse
) 的配置搜索 VHD 更新找到了这个,发现该文件夹实际上不是 DSC 配置文件夹。