Hi Guys,
I have an unattended.xml file which setup parse well. I would like to dynamicaly modify it before launching setup according the hardware detected.
For instance, I would like to add a partition and format it if the disk is big enough. I found how to detect disk size in powershell, but I can't find a way to modify the xml file
So, I would like to add
<CreatePartition wcm:action="add">
<Order>3</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
I made some tries without success.
$Xml contains the xml file.
To create the data, I found two ways :
Long :
$NewPartition = $Xml.CreateElement("CreatePartition")
$Order = $Xml.CreateElement("Order")
$NewPartition.AppendChild($Order)
$OrderValue = $Xml.CreateTextNode("3")
$Order.AppendChild($OrderValue)
<...>
Or :
$NewPartition = [xml] '<CreatePartition><Order>3</Order><Type>Primary</Type><Extend>true</Extend></CreatePartition>'
Then, how to add $NewPartition to the right place in $Xml ?
Something like this ?$Xml.unattend.settings[1].component[1].DiskConfiguration.disk.CreatePartitions.AppendChild($NewPartition)
Could someone give me a correct code ?
Thank you very much
ML
Here are the content of my unattended.
<component name="Microsoft-Windows-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">
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Size>350</Size>
<Type>Primary</Type>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
==> Add here !
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Order>1</Order>
<PartitionID>1</PartitionID>
<Label>System</Label>
<Format>NTFS</Format>
<Active>true</Active>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<Order>2</Order>
<PartitionID>2</PartitionID>
<Format>NTFS</Format>
<Label>Windows</Label>
</ModifyPartition>
</ModifyPartitions>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
ML