我试图使用powershell和XPath来选择下面的xml示例中显示的name属性.
$xml_peoples= $file.SelectNodes("//people")
foreach ($person in $xml_peoples){
echo $person.attributes
#echo $person.attributes.name
}
Run Code Online (Sandbox Code Playgroud)
上面是运行试图获取名称的代码,但它似乎不起作用.有什么建议?
<peoples>
<person name='James'>
<device>
<id>james1</id>
<ip>192.192.192.192</ip>
</device>
</person>
</peoples>
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我试图运行一个powershell脚本作为没有"脚本运行"权限的特定用户登录.如果我想以不同的用户身份运行脚本,是否可以将凭据作为参数添加到脚本中?
./Get-Something-computerName SERVER1 -filePath C:\ Whatever -credentials ??
提前干杯!(Powershell noob)