Я пытаюсь добавить новый элемент RunSynchronousCommand
к приведенному ниже коду unattend.xml
, но немного застрял, так как вложил пару уровней в.
До сих пор я пробовал такие подходы (среди многих других!), Но сейчас бьюсь головой о стол, поэтому помощь приветствуется.
$new = $doc.unattend.settings.component.RunSynchronous.RunSynchronousCommand[0].Clone()
$new.action = 'add'
$new.order = 3
$new.Path = "C:\ProgramData\Amazon\EC2-Windows\Launch\Sysprep\my_powershell_file.ps1"
$doc.unattend.InsertAfter($new, $doc.unattend.settings.component.RunSynchronous.RunSynchronousCommand[1])
Этот выдает ошибку:
Исключение вызывает "InsertAfter" с аргументом (ами) "2": "Ссылочный узел не является дочерним по отношению к этому узлу."
Это unattend.xml
:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="generalize">
<component name="Microsoft-Windows-PnpSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotCleanUpNonPresentDevices>true</DoNotCleanUpNonPresentDevices>
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>*</ComputerName>
<CopyProfile>true</CopyProfile>
<RegisteredOrganization>Amazon</RegisteredOrganization>
<TimeZone>UTC</TimeZone>
</component>
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>net user Administrator /ACTIVE:NO /LOGONPASSWORDCHG:NO /EXPIRES:NEVER /PASSWORDREQ:NO</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>2</Order>
<Path>"C:\ProgramData\Amazon\EC2-Windows\Launch\Sysprep\SysprepSpecialize.cmd"</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings>
</unattend>
Я пытаюсь добавить это:
<RunSynchronousCommand wcm:action="add">
<Order>3</Order>
<Path>"C:\ProgramData\Amazon\EC2-Windows\Launch\Sysprep\my_powershell_file.ps1"</Path>
</RunSynchronousCommand>