本文介绍了如何从XML元素运行一段PowerShell代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我有一个描述要求的XML文档。如果我在Values标记之间有Powershell代码,我可以以某种方式提取它然后运行它吗?I have an XML document that describes requirements. If I had Powershell code between the Values tag, could I somehow extract it and then run it?<field name="c"> <Required>TRUE</Required> <Description> Three letter country code where the individual receives company correspondence Must be set to the appropriate ISO 3166-1 "alpha-3" code. The most common values are "USA" (United States) and "CAN" (Canada). </Description> <Values> Get-ADUser -filter * </Values></field> 我的尝试: $ standard = [xml](Get-ContentC:\ Users \ *** \Documents\Standard.xml) $ fields = $ standard.SelectNodes(// UsersDefaultOU / field) $ code = $ fields [0] .ValuesWhat I have tried:$standard = [xml] (Get-Content "C:\Users\***\Documents\Standard.xml")$fields = $standard.SelectNodes("//UsersDefaultOU/field")$code = $fields[0].Values推荐答案 standard = [xml](Get-ContentC:\ Users \ *** \Documents\Standard.xml)standard = [xml] (Get-Content "C:\Users\***\Documents\Standard.xml") fields = standard.SelectNodes(// UsersDefaultOU / field)standard.SelectNodes("//UsersDefaultOU/field") 这篇关于如何从XML元素运行一段PowerShell代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-06 11:39