locked
Analyze multiple DHCP servers RRS feed

  • Question

  • Hello All,

    I need to analyze more than 100 servers and get how many scopes\addressess servers provides. 

    My script is: 

    $servers= "link to csv"
    $results = foreach ($server in $servers) 
    {
      Get-DhcpServerv4Statistics -ComputerName $server | select -property servername,ServerStartTime,totalscopes,addressesinuse   
      } 
    $results  

    output is:

    servername ServerStartTime     totalscopes addressesinuse
    ---------- ---------------     ----------- --------------
                     2020-02-15 21:05:55         238          10757

    Is here some way how to add real server name to output?

    • Edited by Jerzy_VFR Thursday, February 20, 2020 7:20 PM
    Thursday, February 20, 2020 7:19 PM

All replies

  • Start by doing this:

    Get-DhcpServerv4Statistics -ComputerName <pick one server> | Get-Member

    Then pick the server name property you want.  It is either MachineName or PSComputerName


    \_(ツ)_/

    Thursday, February 20, 2020 8:01 PM
  • Do not know why, but I am still unsuccessful.

    $servers= Get-Content -Path "link to csv" 
    $results = foreach ($server in $servers) 
    {
      Get-DhcpServerv4Statistics -ComputerName $server | Format-Table -property MachineName,PSComputerName,TotalScopes,Available,InUse
      } 
    $results 

    output is:

    MachineName PSComputerName TotalScopes Available InUse   
           -----------      --------------    -----------    --------- -----
                                                                  5       893   184

    Sunday, February 23, 2020 8:41 AM
  • Get-Content link.csv |
        ForEach-Object{
            Get-DhcpServerv4Statistics -ComputerName $_
        } | 
        Format-Table -property MachineName,PSComputerName,TotalScopes,Available,InUse


    \_(ツ)_/

    Sunday, February 23, 2020 12:23 PM