Thursday, March 30, 2017

Powershell 4 - Get authorized DHCP server

You can use the following command to get all authorized DHCP server:

The output will be the IP and DNSName of the server.

You can add out-gridview to easy filter or copy it to Excel.
Get-DhcpServerInDC | Out-GridView

If you want to instant filter on name or IP address you can do it this way:
$DEDHCPs = Get-DhcpServerInDC | where {($_.DNSName –like “DE*”)}

$ipDHCPs = Get-DhcpServerInDC | where {($_.IPAddress –like “10.15*”)}

You can also write the output directly to a file. Just use export-csv:
Get-DhcpServerInDC | where {($_.IPAddress –like “10.15*”)} | Export-Csv c:\admin\dhcps.csv -NoTypeInformation

or using >c:\admin\dhcps.txt (same output like in PS)

Get-DhcpServerInDC | where {($_.IPAddress –like “10.15*”)} >c:\admin\dhcps.txt

No comments:

Post a Comment