我有一个PS脚本可以从XML文件读取值:
PS D:\> $xml = [xml](Get-Content C:\Users\myuser\.VirtualBox\VirtualBox.xml)
PS D:\> $VMFolder = $xml.VirtualBox.Global.SystemProperties.defaultMachineFolder
PS D:\> echo $VMFolder
D:\VirtualboxVMs
xml文件示例:
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.12-windows">
<Global>
<SystemProperties defaultMachineFolder="D:\VirtualboxVMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>
</Global>
</VirtualBox>
谁能给我一个例子,如何使用PowerShell将defaultMachineFolder =“ D:\ VirtualboxVMs”的值更改为“ D:\ newlocation”?
答案 0 :(得分:0)
类似
$xml.VirtualBox.Global.SystemProperties.defaultMachineFolder = "D:\VirtualboxVMs"
$xml.Save("C:\Users\myuser\.VirtualBox\VirtualBox.xml")
应该做到这一点