Use the Select-XML and Import-Clixml cmdlets for this or the XML .Net name space. It is why they exist. PowerShell by design is XML heavy under the covers.
There are tons of articles and examples all over the web regarding using PowerShell to read / parse create / modify / update XML files. It’s a very common use case. Just do a quick search for ‘PowerShell search XML’, be prepared for a long list.
Also, the Write-Verbose with the color stuff is wrong. That cmdlet will not do that. To do that you’d use Write-Host for colors. Yet unless you really need color, avoid Write-Host. Write-Output is the default, which sends stuff to the screen and is pipeline friendly and you don’t necessarily need to specify that either, unless it’s you coding style or organization coding standards policy.
import-clixml is only for xml created with export-clixml.
import-clixml file.xml
import-clixml : Element 'Objs' with namespace name 'http://schemas.microsoft.com/powershell/2004/04' was not found. Line 1, position 2.
At line:1 char:1
+ import-clixml file.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Clixml], XmlException
+ FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.PowerShell.Commands.ImportClixmlCommand
Use select-xml or cast a string array to [xml] like this: