问题
I'm running a powershell file which are going to gather information an save it to an XML-file. This script will run on several computers, and so I want to save them all to a rootpath. The question is, how do I save an XML-file to root on a computer?
To specify: The script will always run on a local computer, hence I need to save the xml file to a local path..
回答1:
Basicly the path to save on a root is:
\\servername\c$\myfile.xml
This is the path to save in the c:\ root folder of a remote machine.
You need local administrator credentials of the server.
回答2:
If I understood correctly.. If you have access to the root drive of the computers in question... this will save each xml file, named after its computer name, in the C drive of each computer.
"comp1","comp2","comp3" | Foreach-Object {
$xml = ....
$xml | Out-File -Path "\\$_\c$\$_.xml"
}
来源:https://stackoverflow.com/questions/10085418/powershell-saving-file-to-root