This one gets me every time, and it seems each time I do it, it’s a slightly different scenario so looking back at my old stuff isn’t helping me make it work. I have an XML file formatted as
<Configuration>
<StudySearchLayout>
<Column Id="LastName" Hidden="n" />
<Column Id="FirstName" Hidden="n" />
<Column Id="Gender" Hidden="y" />
</StudySearchLayout>
</Configuration>
My main objective is to hidden="n"
on all columns. I tried this:
$File = ".File.xml"
[xml]$XML = gc $File
$columns = $XML.Configuration.StudySearchLayout.Column
ForEach($column in $columns){
$column.hidden = "n"
}
$XML.Save($File)
If I go back and run $columns.hidden
, PowerShell shows the value I’m looking for, but it doesn’t appear to actually save anything in the file… Can someone help me figure out what I’m doing wrong?