6

I'm using powerShell, and I want to use lower-case() in a XPath.Something like that

//Machines/Machine[lower-case(@FQDN)=lower-case('machine2.mydomain.com')]

The documentation indicate that I need XPath 2.0, how can I check the version of XPath installed on my server?

Anas
  • 5,622
  • 5
  • 39
  • 71
  • Not sure if i understand your question but are you just looking for lowercase in powershell? On any string you can user `.ToLower()` for example `"IDONTKNOWWHATWEREYELLINGABOUT".ToLower()` would return `idontknowwhatwereyellingabout`. Not sure about the Xpath part of the question? – Matt Jul 22 '14 at 20:16
  • I found this in regards to checking xpath version: http://stackoverflow.com/questions/7951879/which-version-of-xpath-and-xslt-am-i-using. The higest rated answer in the second paragraph. – Matt Jul 22 '14 at 20:21
  • The xpath used with windows event logs is even more crippled. – js2010 Feb 22 '20 at 18:20

2 Answers2

7

As of 2012, Microsoft was officially not supporting XPath 2.0 in the .NET Framework (which is what you'll be using from PowerShell, unless you pull in a 3rd-party library) and as recently as last year it was still not happening. Given that they said a decade ago that they weren't going to implement it, and it hasn't happened yet - don't count on it ever happening.

See XPath and XSLT 2.0 for .NET? for alternatives.

Community
  • 1
  • 1
alroc
  • 27,574
  • 6
  • 51
  • 97
0

You could do it in powershell without worrying about case:

$xml = [xml](get-content file.xml)                                     
$xml.machines.machine | ? fqdn -eq machine2.mydomain.com


FQDN
----
machine2.mydomain.com
js2010
  • 23,033
  • 6
  • 64
  • 66