Wednesday, 28 August 2013

Get-DHCPPerf.Ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets and displays perf counters for DHCP 
  4. .DESCRIPTION 
  5.     This script uses the Get-Counter cmdlet to get all 
  6.     the counters for DHCP. The function does this for one 
  7.     DHCP server at a time. 
  8. .NOTES 
  9.     File Name  : Show-.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15. .EXAMPLE 
  16.     C:\Foo> Get-DHCPPerformanceCounters -comp dhcp2 
  17.      Performance counters for: dhcp2 
  18.      \\dhcp1\dhcp server\failover: bndupd dropped.                                           0 
  19.      \\dhcp1\dhcp server\failover: transitions to recover state.                             8 
  20.      \\dhcp1\dhcp server\failover: transitions to partner-down state.                        0 
  21.      \\dhcp1\dhcp server\failover: transitions to communication-interrupted state.           9 
  22.      \\dhcp1\dhcp server\failover: bndupd pending in outbound queue.                         0 
  23.      \\dhcp1\dhcp server\failover: bndack received/sec.                                      0 
  24.      \\dhcp1\dhcp server\failover: bndack sent/sec.                                          0 
  25.      \\dhcp1\dhcp server\failover: bndupd received/sec.                                      0 
  26.      \\dhcp1\dhcp server\failover: bndupd sent/sec.                                          0 
  27.      \\dhcp1\dhcp server\denied due to nonmatch.                                             0 
  28.      \\dhcp1\dhcp server\denied due to match.                                                0 
  29.      \\dhcp1\dhcp server\offer queue length                                                  0 
  30.      \\dhcp1\dhcp server\releases/sec                                                        0 
  31.      \\dhcp1\dhcp server\declines/sec                                                        0 
  32.      \\dhcp1\dhcp server\nacks/sec                                                           0 
  33.      \\dhcp1\dhcp server\acks/sec                                                            0 
  34.      \\dhcp1\dhcp server\informs/sec                                                         0 
  35.      \\dhcp1\dhcp server\requests/sec                                                        0 
  36.      \\dhcp1\dhcp server\offers/sec                                                          0 
  37.      \\dhcp1\dhcp server\discovers/sec                                                       0 
  38.      \\dhcp1\dhcp server\conflict check queue length                                         0 
  39.      \\dhcp1\dhcp server\active queue length                                                 0 
  40.      \\dhcp1\dhcp server\milliseconds per packet (avg).                                     28 
  41.      \\dhcp1\dhcp server\packets expired/sec                                                 0 
  42.      \\dhcp1\dhcp server\duplicates dropped/sec                                              0 
  43. #> 
  44.  
  45.  
  46.  
  47.  
  48. # Get-DHCPPerformanceCounters function 
  49.  
  50. Function Get-DHCPPerformanceCounters { 
  51. Param ( 
  52. $comp = 'localhost'
  53.  
  54. # Get DHCP Counters 
  55. $set = get-counter -listset "DHCP Server" 
  56. $ctrs = $set.counter 
  57.  
  58. " Performance counters for: {0}" -f $comp 
  59. # For each counter, get the sample 
  60. foreach ($ctr in $ctrs) { 
  61.  $sample = (get-counter $ctr).countersamples 
  62.  
  63.  
  64.  "{0,-78} {1,10}" -f $sample.path, $sample.cookedvalue 
  65.  
  66.  
  67.  
  68. # Now test it 
  69. Get-DHCPPerformanceCounters -comp dhcp1 
  70. Get-DHCPPerformanceCounters -comp dhcp2 
Technorati Tags:

No comments: