# Getting DHCP Server scope from multiple servers

**URL:** <https://forums.powershell.org/t/getting-dhcp-server-scope-from-multiple-servers/7190>\
**Category:** PowerShell Help\
**Created:** [September 14, 2016, 5:16am UTC](https://forums.powershell.org/t/getting-dhcp-server-scope-from-multiple-servers/7190 "2016-09-14T05:16:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amit-aman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/amit-aman/32/320_2.png) [@amit-aman](https://forums.powershell.org/u/amit-aman)\
**Post date:** [September 14, 2016, 5:16am UTC](https://forums.powershell.org/t/getting-dhcp-server-scope-from-multiple-servers/7190/1 "2016-09-14T05:16:00Z")

</div>

Hello Team,

Hope you all are doing good… back again 🙂

This time I am trying to get the DHCP server scope from 2 servers and trying to collect the report into a csv file;  
I am using following script;

$ab = Get-DhcpServerv4Scope  
$a = $ab[6,8]  
foreach($b in $a)  
{  
Get-DhcpServerv4Scope -ComputerName $b.dnsname | Export-Csv c:\report.csv  
}

This script is giving me the output from only one server and that too randomly. I cross verified it using  
**Get-Help Get-DhcpServerv4Scope -full** , found that **ComputerName** parameter is accepting a single value.  
Kindly help me with the workaround.

Thanks

---

<div class="post-metadata">

**Author:** ![erik-sundin](https://avatars.discourse-cdn.com/v4/letter/e/f0a364/32.png) [@erik-sundin](https://forums.powershell.org/u/erik-sundin)\
**Post date:** [September 14, 2016, 5:56am UTC](https://forums.powershell.org/t/getting-dhcp-server-scope-from-multiple-servers/7190/2 "2016-09-14T05:56:19Z")

</div>

Hey,

Your problem is not with Get-DhcpServer4Scope, but with Export-Csv, you need to use the -append parameter. From the Help:

"-Append

Indicates that this cmdlet adds the CSV output to the end of the specified file. Without this parameter, Export-CSV replaces the file contents without warning.

This parameter was introduced in Windows PowerShell 3.0."

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [September 14, 2016, 6:55am UTC](https://forums.powershell.org/t/getting-dhcp-server-scope-from-multiple-servers/7190/3 "2016-09-14T06:55:17Z")

</div>

Collect all of the results and then export to a CSV:

```
$ab = Get-DhcpServerv4Scope
$a = $ab[6,8]
$results = foreach($b in $a) {
    Get-DhcpServerv4Scope -ComputerName $b.dnsname 
}

$results | Export-Csv c:\report.csv -NoTypeInformation
```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:40pm UTC](https://forums.powershell.org/t/getting-dhcp-server-scope-from-multiple-servers/7190/4 "2024-05-16T20:40:20Z")

</div>

Closed on May 16, 2024, 8:40pm UTC


