Sunday, 25 April 2021

How to Get all DHCP Server in the Forest

 PowerShell - DHCP Server List



Get-DhcpServerInDC






DHCP Server List with OS

$DHCPServers = Get-DhcpServerInDC

 

 ForEach ($DHCPServer in $DHCPServers){

   $OSInfo = Get-CIMInstance -ComputerName $DHCPServer.DnsName -ClassName Win32_OperatingSystem

}

 

 

ForEach ($DHCPServer in $DHCPServers){

   $OSInfo = Get-CIMInstance -ComputerName $DHCPServer.DnsName -ClassName Win32_OperatingSystem

   [pscustomobject]@{

      ServerName = $DHCPServer.DnsName;

      IPAddress=$DHCPServer.IpAddress;

      OS=$OSInfo.Caption

    }




No comments:

Post a Comment