Forum Discussion
charlie4872
May 21, 2021Brass Contributor
Export Results To Individual Files
Hello I am trying to export .xml files from a list of servers so it creates a separate file for each server in a loop. But the problem is it looks like the loop would overwrite the results from each ...
- May 22, 2021
Hello charlie4872,
One of the options would be to add $computer to resulting filename:
$computers = get-content .\servers.txt foreach ($computer in $computers){ Export-DhcpServer -ComputerName $computer -File "C:\DHCP_EXPORT\$computer-DHCP-Config.xml" -Force }
This will create a separate file for every computer in the input file in your DHCP_EXPORT folder.
Hope that helps
AndySvints
May 22, 2021Iron Contributor
Hello charlie4872,
One of the options would be to add $computer to resulting filename:
$computers = get-content .\servers.txt
foreach ($computer in $computers){
Export-DhcpServer -ComputerName $computer -File "C:\DHCP_EXPORT\$computer-DHCP-Config.xml" -Force
}
This will create a separate file for every computer in the input file in your DHCP_EXPORT folder.
Hope that helps
- charlie4872May 24, 2021Brass ContributorThanks AndySvints this does exactly what I was looking for!