Export DHCP scope options to file

howbs2002 106 Reputation points

Is there a PowerShell command to export specific scope options for all scopes on a single server.

For example, the command below gets all scopes on mydhcpserver and exports their properties to a csv file.

However, I only see scope properties and not scope options, such as "Option 043 / Vendor Specific Info".

Get-DhcpServerv4Scope -ComputerName "mydhcpserver" | Select * | export-csv export.csv -NoTypeInformation

I tried a txt file but that is unusable - netsh dhcp server export c:\DHCP\myscopes.txt

Thanks in advance.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,398 questions
{count} votes

Accepted answer
  1. Rich Matheisen 45,111 Reputation points

    Something like this might be what you're looking for:

    $dhcpserver = 'srv01','srv07'  
    $optionids = 3,6  
    $dhcpserver |  
            $servername = $_  
            Get-DHCPServerv4Scope -ComputerName $_ |   
                    $scopeid = $_.ScopeId  
                    Get-DHCPServerv4OptionValue -ComputerName $_ -ScopeID $scopeid -OptionId $optionids |  
                                DHCPServer = $servername  
                                ScopeID = $scopeid  
                                OptionId = $_.OptionId  
                                Name =  $_.Name  
                                Value = $_.Value -join ';'  
             } | Export-Csv c:\junk\scopids.csv -NoTypeInformation  

1 additional answer

Sort by: Most helpful
  1. cthivierge 4,056 Reputation points

    You can use the PS command: Get-DhcpServerv4OptionValue -ComputerName MyDC -ScopeId

    This should give you the result you are looking for