Home > Back-end >  How to Edit a VisualElementsManifest.xml with a PowerShell Script?
How to Edit a VisualElementsManifest.xml with a PowerShell Script?

Time:07-16

I have looked at quite a few posts like this one on how to edit XML files with PowerShell, however, I cannot get any of the solutions to work in my case (I have only a little experience with PowerShell and scripting).

I want to edit Windows Store.VisualElementsManifest.xml located in C:\ProgramData\TileIconify\Windows Store to change it from this:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" GeneratedByTileIconifier="true">
  <VisualElements ShowNameOnSquare150x150Logo="on" Square150x150Logo="VisualElements\MediumIconWindows Store.png" Square70x70Logo="VisualElements\SmallIconWindows Store.png" ForegroundText="dark" BackgroundColor="#41413D" TileIconifierColorSelection="Default" TileIconifierCreatedWithUpgrade="true" />
</Application>

to this:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" GeneratedByTileIconifier="true">
  <VisualElements ShowNameOnSquare150x150Logo="on" Square150x150Logo="VisualElements\MediumIconWindows Store Dark.png" Square70x70Logo="VisualElements\SmallIconWindows Store Dark.png" ForegroundText="dark" BackgroundColor="#41413D" TileIconifierColorSelection="Default" TileIconifierCreatedWithUpgrade="true" />
</Application>

I am getting confused because of the fact that the strings in the VisualManifest.xml files are full of quotes and spaces, which break the PowerShell scripts, and none of the threads I have read explain how to deal with that.

CodePudding user response:

It seems you're looking to update 2 properties of your XML, Square150x150Logo and Square70x70Logo, if that's the case you could try this:

$filePath = 'Path\to\Windows Store.VisualElementsManifest.xml'
$xml = [xml]::new()
$xml.Load($filePath)
$visualElements = $xml.Application.VisualElements
$visualElements.Square150x150Logo = "VisualElements\MediumIconWindows Store Dark.png"
$visualElements.Square70x70Logo   = "VisualElements\SmallIconWindows Store Dark.png"
$xml.Save($filePath)
  • Related