Forum Discussion

charlie4872's avatar
charlie4872
Brass Contributor
May 21, 2021
Solved

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 ...
  • AndySvints's avatar
    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

     

Resources