Author Posts

June 8, 2017 at 1:12 pm

I am trying to update a value in XML file. I can get to that property as below, please help;

PS C:\> ($xml2.unattend.settings.component).registeredorganization
xxxx Group Headquarters, IT Services

But when I try to update the value of that property with below command it gives me error ;

PS C:\> $XMLTest= ($xml2.unattend.settings.component).registeredorganization
PS C:\> $XMLTest.RegisteredOrganization = $registeredOrganization
The property 'RegisteredOrganization' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:1


June 8, 2017 at 1:22 pm

There is not a sample of your XML, but looking at what you have, you have already included "registeredorganization" in your variable and there is probably not a registeredorganization property of registeredorganization like you are trying to set

$XMLTest= ($xml2.unattend.settings.component).registeredorganization

So putting RegisteredOrganization you are basically looking for this in your xmls
($xml2.unattend.settings.component).registeredorganization.RegisteredOrganization = $registeredOrganization

You likely just need to drop the second RegisteredOrganization

PS C:\> $XMLTest= ($xml2.unattend.settings.component).registeredorganization
PS C:\> $XMLTest = $registeredOrganization

June 8, 2017 at 3:25 pm

Hi Curtis,
I found the xml I am working with has a namespace.What do I need to do in this case?
Below is the snap of my XML file, I need to update the value for 'RegisteredOrganization';


June 8, 2017 at 7:33 pm

Hey Kishor, you will likely have to use a gist to post your xml. This forum tends to strip it out.

June 8, 2017 at 7:57 pm

mistake post. Please ignore

June 9, 2017 at 7:01 am

Hi Curtis,
Below is link for my xml;


June 9, 2017 at 1:27 pm

There are some issues with your xml which I will assume are type-os in the provided example and not in your actual file. The issue you are having with setting your value is that you have multiple components that match.

$xml2.unattend.settings.component will match the first component in the file where name is blank, and it will match the second component in the file where name is "Microsoft-Windows-". The result is that at this point you have a collection of object that .registeredorganization is looking in, and you cannot set the value like this across a collection.

What you need to do is select the specific component you need so that you have just the single object when you are trying to set the registeredorganization value.


xxxx Group Headquarters, IT Services

June 9, 2017 at 3:06 pm

Thanks a lot Curtis! your solution has solved my problem. Now I am able to get to the value without worrying about the namespaces involved in the XML file.