Aklımda Kalası Kelimeler

* давайте работать вместе
* Zarf ve Mazruf, Zerafet(xHoyratlık) ile aynı kökten(za-ra-fe) gelir
* Bedesten
* Suç subuta ermiştir - Suç sabit olmuştur
Netsh etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Netsh etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

16 Nisan 2015 Perşembe

Fiddler ile SQL Server'dan yapılan Web Servis Çağrılarını İzlemek

Fiddler and Microsoft Sql Server

SQL Prosedürmüzde sp_OACreate ile Web Servisi çağrısı yapacağımız bir OLE nesnesi örneğini yaratıp üstünden bir HTTP paketi gönderebiliriz ama Fiddler bunu göstermeyecek. Haydi başlayalım...
Temel itibarıyla aşağıdaki basit kod ile herhangi bir web sayfasını mssql içinden çağırabilirsiniz:
DECLARE @Request INT,
  @hr INT,
  @activeX VARCHAR(50) = 'Msxml2.ServerXMLHTTP.6.0';

 SET @activeX = '{88d96a0b-f192-11d4-a65f-0040963251e5}';
 EXEC @hr = sp_OACreate @activeX, @Request OUT;
 SELECT @hr, @Request
 
 EXEC sp_OAMethod @Request, 'open', NULL, 'GET','https://www.random.org/cgi-bin/randbyte?nbytes=1307&format=h', 'false'
 EXEC sp_OAMethod @Request, 'send', null, ''
  
 DECLARE @ResponseText Varchar(4000)
 EXEC sp_OAMethod @Request, 'responseText', @ResponseText OUTPUT
 SELECT @ResponseText
 Exec sp_OADestroy @Request
 
 IF @hr <> 0
 BEGIN
       DECLARE @src varchar(255), @desc varchar(255)
    EXEC sp_OAGetErrorInfo @Request, @src OUT, @desc OUT 
    SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
 END
 ELSE
    Exec sp_OADestroy @Request

Ekşi Sözlük'te Ole tanımları:
Biraz anlatayım ne nedir diye. sp_OACreate ile MSSQL içinde bir OLE nesnesinin örneğini yaratır.

ole 2.0 kendi icinde (bkz: com) (bkz: activex) gibi teknolojileri icherir..

nesne baglama ve nesne gomme(yerleshtirme). bir yazilim tarafindan olushturulan bir nesnenin ozelliklerini kaybetmeden bashka bir yazilim tarafindan kullanilabilmesini saglar. bu tur nesneler uzerinde deishiklik yapmak istenirse nesne uzerinden orjinal yazilima baglanmak olanaklidir.

object linking and embedding kisaltmasidir turkcesi ise nesne baglama ve gömme olarak cevrile bilir microsoft office uygulamaları arasında verialı$veri$ini mümkün kılan teklojinin adıdır.ole'nin 2 farkli boyutta islem gormektedir.bunlar baglama ve gömme ne demek simdi bu derseniz sole ki excelde bi islem yaptınız worldbelgesine transferini yapmayı dusunuyorsunuz iste bu hadise bunu mumkun kılmaktadır.

Demek ki bizim bir nesnemiz var ve ondan bir örnek yaratıp, örneğimiz üzerinden işlemler yapmak istiyoruz.

Peki buradaki OLE nesnemiz olan Msxml2.ServerXMLHTTP.6.0 kimdir?

Önce MSXML'den başlayalım. Microsoft XML Core Services (MSXML) W3C uyumlu XML API leri ile yüksek performanslı XML temelli uygulamalar geliştirmeye yarar. Bu kısım biraz genişçe devam edebilir ama konumuzdan sapmayacağım. Neydi konumuz Fiddler ile SQL Server üstünden yaptığımız Web Servisi çağrılarını görüntülemek.
Sırada bu örneği yaratırken kullandığımız INT tipinde @hr ve @Request değişkenleri. @hr sayesinde bu örnekleme işimiz eğer 0 dan başka bir sonuç gelmişse HATA olarak değerlendirecek ve hatayı görüntülemek için IF @hr <> 0 satırını kullanacağız. Burada detaylandırılacak bir şey varsa ben bilmiyorum. Gelin ekran çıktılarına bakalım:

Peki BAŞARISIZ bir örneklendirmeye bakalım:

Açıktırki örneklendiremememiz makinede olmayan bir OLE nesnesini kullanmak arzumuzdan.
Msxml2.ServerXMLHTTP.6.0 OLE nesnesi sistemimizde kayıtlıyken

Msxml2.ServerXMLHTTP.5.0 Registry'de kayıtlı değil.
Sorgulamak için registry sorgusu da deneyebilirsiniz:
C:\>reg query hkcr /f xmlhttp

HKEY_CLASSES_ROOT\Microsoft.XMLHTTP
HKEY_CLASSES_ROOT\Microsoft.XMLHTTP.1.0
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP.3.0
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP.4.0
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP.6.0
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP.3.0
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP.4.0
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP.6.0
End of search: 10 match(es) found.

C:\>

Ayrıca OLE nesnelerimizi ProgId ya da ClsId ile çağırabiliriz

Peki CLS Id nedir?

Ya ProgId?

OLE nesnelerimizi eğer CLS ID leri ile yaratmak istersek önce CLS ID lerini nerede bulabileceğimize bakalım:

Ve şimdide CLS ID ile SQL içinde örnekleme işine bakalım:

Devamını yazacağım ama önce Verdi nin konserine gitmeliyim. Yarın devam ederim ;)

Bir Verdi Konseri harikaydı...

Fiddler SQL'i nasıl dinler

Normalde dinlemesini bekleriz ama Fiddler'e düşmez SQL web servis çağrılarınız. SQL Server sizin login olduğunuz oturum üstünden çalışmadığı için Fiddler görüntüleyemeyecektir.
Aşağıda nasıl yapacağımızı görelim:
Artık fiddler sql web service çağrılarını görebileceksiniz.

Neden tüm web servis çağrılarım Fiddler'e düşmüyor

Önce düşen web servis sonuçları var ve düşmeyen var. O halde sorunu tespit için fiddlere baktım ve http talebinin sonuçlarının boyutundan şüphelendim. Bunu test etmek için dönen cevabın boyutunu ayarlayabileceğim bir site buldum. Url adresinden dönecek sonucun boyutunu değiştirebilirsiniz https://www.random.org/cgi-bin/randbyte?nbytes=1324&format=h ve fiddler üstünde görebiliyorsunuz.
SQL kodumuzla çağrı yapalım ve sonucu SQL tarafından alınamayan durumu inceleyelim:
DECLARE @Request INT,
  @hr INT,
  @activeX VARCHAR(50) = 'Msxml2.ServerXMLHTTP.6.0';
  SET @activeX = '{88d96a0b-f192-11d4-a65f-0040963251e5}';

EXEC @hr = sp_OACreate @activeX, @Request OUT;
EXEC sp_OAMethod @Request, 'open', NULL, 'GET','https://www.random.org/cgi-bin/randbyte?nbytes=1307&format=h', 'false'
EXEC sp_OAMethod @Request, 'send', null, ''

DECLARE @ResponseText Varchar(4000)
EXEC sp_OAMethod @Request, 'responseText', @ResponseText OUTPUT
SELECT @ResponseText as Response
Exec sp_OADestroy @Request
 
IF @hr <> 0
BEGIN
   DECLARE @src varchar(255), @desc varchar(255)
   EXEC sp_OAGetErrorInfo @Request, @src OUT, @desc OUT 
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
   RETURN
END
ELSE
 Exec sp_OADestroy @Request

Bu kezde başarılı bir web sayfası çağrısını SQL'den yapalım:

Peki Sorun OLE Nesnesinde mi?

SQL'de göremiyoruz ama arada OLE nesnemiz var acaba sorun onda mı? OLE nesnemizin çektiği sonucu bir dosyaya yazalım ve görelim gelen cevabı kesiyor ya da kırpıyormu.
Test için yine fiddler ve OLE nesnemizden örneğimizi yazıp konsoldan çalıştırmak için bir script dosyası oluşturalım.
Dim oXMLHTTP
Dim oStream

Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")

Dim byteSize 
byteSize="1306"

oXMLHTTP.Open "GET", "https://www.random.org/cgi-bin/randbyte?nbytes="+byteSize+"&format=h", False
oXMLHTTP.Send

If oXMLHTTP.Status = 200 Then
 Wscript.Echo oXMLHTTP.responseBody
 Set oStream = CreateObject("ADODB.Stream")
 oStream.Open
 oStream.Type = 1
 oStream.Write oXMLHTTP.responseBody
 oStream.SaveToFile "c:\temp\sonuc"+byteSize+".txt"
 oStream.Close
End If
Yukarıdaki kodumuzun çalışması için MSXML nin internet explorer->internet options -> Security Settings -> Custom Level -> Access data sources accross domains -> Enable ayarının yapılması gerekecek:

4000 altındaki cevapları SQL içinde görebildiğimiz için öncelikle bunu dosyaya yazdırabiliyor muyuz diye bakalım:

SQL'e yazdıramadığımız sonucu bakalım dosyaya yazabilecek miyiz ve acaba OLE nesnemiz mi SQL'e aktarmıyor diye kontrol edelim:
Geldiğimiz noktada sorun sp_OACreate 'in NVarchar(4000) limitine takılmamızmış :) Öğrendiğim adres ve çözmek isterseniz çözümleri için buraya veya buraya tıklayabilirsiniz.

Bu noktadan sonra ben .Net assemblysi yazarak ilgili fonksiyonlarını çağırmayı tercih edeceğim :)

Azim ve bilgi dolu okumalar olsun....

27 Ocak 2012 Cuma

ARP (Address Resolution Protocol) Hakkında bakındıklarım

En temiz kaynak tabii ki:

ARP'ın Ön Belleğinin(cache) Görünümü


ARP içine olmayan bir IP adresinin olmayan bir MAC adresi ile kaydı

C:\Users\Administrator>arp -s 192.168.101.101 00-aa-bb-cc-dd-ee
C:\Users\Administrator>arp -a 192.168.101.101

Interface: 10.214.36.74 --- 0xd
  Internet Address      Physical Address      Type
  192.168.101.101       00-aa-bb-cc-dd-ee     static

Netsh kullanımı: technet.microsoft.com

C:\Users\Administrator>

ARP Ön Belleğinin(cache) Silinmesi

Silmeden önce bakalım:

Silme işlemi:

Sildikten sonra:


Bir dizi işlem

  • Ön belleği silelim.
    C:\Users\Administrator>netsh interface ip delete arpcache
    Ok.
    



  • Olmayan IP adresi ile olan bir MAC adresini eşleyerek girelim:
    C:\Users\Administrator>arp -s 192.168.101.101 00-14-a5-76-19-3f
    
    
  • ARP Tablomuzda son duruma bakalım:
    C:\Users\Administrator>arp -a
    
    Interface: 10.214.36.74 --- 0xd
      Internet Address      Physical Address      Type
      10.214.36.3           68-b5-99-9a-6e-c0     dynamic
      10.214.36.255         ff-ff-ff-ff-ff-ff     static
      192.168.101.101       00-14-a5-76-19-3f     static
      255.255.255.255       ff-ff-ff-ff-ff-ff     static
    
    Interface: 192.168.68.1 --- 0x10
      Internet Address      Physical Address      Type
      192.168.68.255        ff-ff-ff-ff-ff-ff     static
    
    Interface: 192.168.198.1 --- 0x11
      Internet Address      Physical Address      Type
      192.168.198.255       ff-ff-ff-ff-ff-ff     static
    
    
  • Bu adresi pingleyelim:
    C:\Users\Administrator>ping 192.168.101.101
    
    Pinging 192.168.101.101 with 32 bytes of data:
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    
    Ping statistics for 192.168.101.101:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
    
    
  • MAC adresinin gerçek adresini pingleyelim:
    C:\Users\Administrator>ping 10.214.36.246
    
    Pinging 10.214.36.246 with 32 bytes of data:
    Reply from 10.214.36.246: bytes=32 time=7ms TTL=128
    Reply from 10.214.36.246: bytes=32 time=2ms TTL=128
    Reply from 10.214.36.246: bytes=32 time=2ms TTL=128
    Reply from 10.214.36.246: bytes=32 time=2ms TTL=128
    
    Ping statistics for 10.214.36.246:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 2ms, Maximum = 7ms, Average = 3ms
    
    
  • ARP Tablomuzda son duruma bakalım:
    C:\Users\Administrator>arp -a
    
    Interface: 10.214.36.74 --- 0xd
      Internet Address      Physical Address      Type
      10.214.36.3           68-b5-99-9a-6e-c0     dynamic
      10.214.36.246         00-14-a5-76-19-3f     dynamic
      10.214.36.255         ff-ff-ff-ff-ff-ff     static
      192.168.101.101       00-14-a5-76-19-3f     static
      255.255.255.255       ff-ff-ff-ff-ff-ff     static
    
    Interface: 192.168.68.1 --- 0x10
      Internet Address      Physical Address      Type
      192.168.68.255        ff-ff-ff-ff-ff-ff     static
    
    Interface: 192.168.198.1 --- 0x11
      Internet Address      Physical Address      Type
      192.168.198.255       ff-ff-ff-ff-ff-ff     static
    
    C:\Users\Administrator>
Tüm görünümü:
C:\Users\Administrator>netsh interface ip delete arpcache
Ok.

C:\Users\Administrator>arp -s 192.168.101.101 00-14-a5-76-19-3f

C:\Users\Administrator>ping 192.168.101.101

Pinging 192.168.101.101 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.101.101:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Users\Administrator>arp -a

Interface: 10.214.36.74 --- 0xd
  Internet Address      Physical Address      Type
  10.214.36.3           68-b5-99-9a-6e-c0     dynamic
  10.214.36.255         ff-ff-ff-ff-ff-ff     static
  192.168.101.101       00-14-a5-76-19-3f     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

Interface: 192.168.68.1 --- 0x10
  Internet Address      Physical Address      Type
  192.168.68.255        ff-ff-ff-ff-ff-ff     static

Interface: 192.168.198.1 --- 0x11
  Internet Address      Physical Address      Type
  192.168.198.255       ff-ff-ff-ff-ff-ff     static

C:\Users\Administrator>ping 10.214.36.246

Pinging 10.214.36.246 with 32 bytes of data:
Reply from 10.214.36.246: bytes=32 time=7ms TTL=128
Reply from 10.214.36.246: bytes=32 time=2ms TTL=128
Reply from 10.214.36.246: bytes=32 time=2ms TTL=128
Reply from 10.214.36.246: bytes=32 time=2ms TTL=128

Ping statistics for 10.214.36.246:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 2ms, Maximum = 7ms, Average = 3ms

C:\Users\Administrator>arp -a

Interface: 10.214.36.74 --- 0xd
  Internet Address      Physical Address      Type
  10.214.36.3           68-b5-99-9a-6e-c0     dynamic
  10.214.36.246         00-14-a5-76-19-3f     dynamic
  10.214.36.255         ff-ff-ff-ff-ff-ff     static
  192.168.101.101       00-14-a5-76-19-3f     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

Interface: 192.168.68.1 --- 0x10
  Internet Address      Physical Address      Type
  192.168.68.255        ff-ff-ff-ff-ff-ff     static

Interface: 192.168.198.1 --- 0x11
  Internet Address      Physical Address      Type
  192.168.198.255       ff-ff-ff-ff-ff-ff     static

C:\Users\Administrator>

Son olarak: ARP'ın kullanımı

C:\Users\Administrator>arp

Displays and modifies the IP-to-Physical address translation tables used by
address resolution protocol (ARP).

ARP -s inet_addr eth_addr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr] [-v]

  -a            Displays current ARP entries by interrogating the current
                protocol data.  If inet_addr is specified, the IP and Physical
                addresses for only the specified computer are displayed.  If
                more than one network interface uses ARP, entries for each ARP
                table are displayed.
  -g            Same as -a.
  -v            Displays current ARP entries in verbose mode.  All invalid
                entries and entries on the loop-back interface will be shown.
  inet_addr     Specifies an internet address.
  -N if_addr    Displays the ARP entries for the network interface specified
                by if_addr.
  -d            Deletes the host specified by inet_addr. inet_addr may be
                wildcarded with * to delete all hosts.
  -s            Adds the host and associates the Internet address inet_addr
                with the Physical address eth_addr.  The Physical address is
                given as 6 hexadecimal bytes separated by hyphens. The entry
                is permanent.
  eth_addr      Specifies a physical address.
  if_addr       If present, this specifies the Internet address of the
                interface whose address translation table should be modified.
                If not present, the first applicable interface will be used.
Example:
  > arp -s 157.55.85.212   00-aa-00-62-c6-09  .... Adds a static entry.
  > arp -a                                    .... Displays the arp table.

2 Mayıs 2011 Pazartesi

PowerShell ve Netsh ile Server, Scope, Leased, Reserved IP ler v.s. alımı


Add-Type -TypeDefinition @"
public struct DHCPDNSConfiguration {
public string Level;
public bool AllowDynamicUpdate;
public string UpdateTrigger;
public bool DiscardStaleRecords;
public bool AllowLegacyClientUpdate;
public int Value;
public override string ToString() {
switch(Value) {
case -1: return (Level=="Server")?"(Default) Update by Client Request With Cleanup":"Inherited from Parent";
case 0: return "Dynamic Updates Disabled";
case 1: return "Update by Client Request Without Cleanup";
case 2: return "Dynamic Updates Disabled";
case 3: return "Update Legacy Clients and by Client Request Without Cleanup";
case 4: return "Dynamic Updates Disabled";
case 5: return "Update by Client Request With Cleanup";
case 6: return "Dynamic Updates Disabled";
case 7: return "Update Legacy Clients and by Client Request With Cleanup";
case 16: return "Dynamic Updates Disabled";
case 17: return "Always Update Clients Without Cleanup";
case 18: return "Dynamic Updates Disabled";
case 19: return "Always Update [Legacy] Clients Without Cleanup";
case 20: return "Dynamic Updates Disabled";
case 21: return "Always Update Clients With Cleanup";
case 22: return "Dynamic Updates Disabled";
case 23: return "Always Update [Legacy] Clients With Cleanup";
default: return "Invalid Configuration";
}
}
}

public struct DHCPIPRange {
public string StartAddress;
public string EndAddress;
public override string ToString() { return StartAddress+" - "+EndAddress; }
}

public struct DHCPOption {
public int OptionID;
public string OptionName;
public string ArrayType;
public string OptionType;
public string[] Values;
public string Level;
public override string ToString() { return OptionName; }
}

public struct DHCPReservation {
public string IPAddress;
public string MACAddress;
public string Scope;
public string Server;
public DHCPOption[] Options;
public DHCPDNSConfiguration DNSConfiguration;
public override string ToString() { return IPAddress; }
}

public struct DHCPLeasedIp {
public string IPAddress;
public string SubnetMask;
public string MACAddress;
public string LeaseExpires;
public string Tip;
public override string ToString() { return IPAddress; }
}

public struct DHCPScope {
public string Address;
public string SubnetMask;
public string Name;
public string Description;
public string State;
public string Server;
public DHCPIPRange[] IPRanges;
public DHCPIPRange[] ExclusionRanges;
public DHCPReservation[] Reservations;
public DHCPLeasedIp[] LeasedIPs;
public int Lease;
public DHCPOption[] Options;
public DHCPDNSConfiguration DNSConfiguration;
public override string ToString() { return Address; }
}

public struct DHCPServer {
public string Name;
public string IPAddress;
public DHCPDNSConfiguration DNSConfiguration;
public int ConflictDetectionAttempts;
public DHCPScope[] Scopes;
public DHCPOption[] Options;
public override string ToString() { return Name; }
}

public struct DHCPScopeStatistics {
public string Scope;
public string Server;
public int TotalAddresses;
public int UsedAddresses;
public int PendingOffers;
public override string ToString() { return Scope; }
}

public struct DHCPServerStatistics {
public string Server;
public int Discovers;
public int Offers;
public int Requests;
public int Acks;
public int Naks;
public int Declines;
public int Releases;
public System.DateTime StartTime;
public int Scopes;
public DHCPScopeStatistics[] ScopeStatistics;
public override string ToString() { return Server; }
}
"@

function Show-DHCPServers {
<#
.Synopsis
Displays a list of all DHCP servers in Active Directory.
.Description
The Show-DHCPServers cmdlet is used to display all DHCP servers registered in Active Directory.
.Outputs
PSObject
.Notes
Name: Show-DHCPServers
Module: Microsoft.DHCP.PowerShell.Admin.psm1
Author: Jeremy Engel
Date: 03.15.2011
#>
$servers = @()
$text = $(Invoke-Expression "cmd /c netsh dhcp show server")
$result = if($text.GetType() -eq [string]){$text}else{$text[($text.Count-1)]}
if($result.Contains("completed successfully")) {
foreach($line in $text) {
if($line.Contains("Server [")) {
$parts = $line.Split("[")
$name = $parts[1].Split("]")[0]
$ip = $parts[2].Split("]")[0]
$server = New-Object PSObject
$server | Add-Member NoteProperty Server($name)
$server | Add-Member NoteProperty IPAddress($ip)
$servers += $server
}
}
return $servers
}
else { Write-Host "ERROR: $result" -ForeGroundColor Red }
}

function Get-DHCPScope {
<#
.Synopsis
Retieves all or specifics scopes for a given server.
.Example
Get-DHCPScope -Server dhcp01.contoso.com
This example retrieves all scopes on dhcp01.contoso.com.
.Example
$server | Get-DHCPScope -Scope 192.168.1.0
Given that $server is the DHCPServer object for dhcp01.contoso.com, this example retrieves the scope 192.168.1.0.
.Description
The Get-DHCPScope cmdlet is used to retieves all or specific DHCP scopes on a given server. The return value for success is one or an array of DHCPScope objects.
.Parameter Server
The value for this parameter can be a DHCPServer object or the name or FQDN of the DHCP server. The designated server must by a valid DHCP server.
.Parameter Scope
The value for this parameter must be the subnet address of the scope.
.Outputs
DHCPScope
.Notes
Name: Get-DHCPScope
Module: Microsoft.DHCP.PowerShell.Admin.psm1
Author: Jeremy Engel
Date: 12.16.2010
#>
Param([Parameter(Mandatory = $true, ValueFromPipeline = $true)][PSObject]$Server,
[Parameter(Mandatory = $false)][string]$Scope
)
$dhcpScopes = @()
$scopeList = @{}
$text = $(Invoke-Expression "cmd /c netsh dhcp server \\$Server show scope")
if($text[2].Contains("Server may not function properly")) { Write-Host "ERROR: $Server is inaccessible or is not a DHCP server." -ForeGroundColor Red; return }
for($i=5;$i -lt $text.Count;$i++) {
if(!$text[$i]) { break }
$parts = $text[$i].Split("-") | %{ $_.Trim() }
$scopeList.Add($parts[0],@($parts[1],$parts[2],$parts[3],$parts[4]))
}

<#
$scopeList:
Name Value
---- -----
10.214.15.128 {255.255.255.128, Disabled, pdawireless, }
10.214.15.0 {255.255.255.128, Active, base, }
#>

foreach($address in $scopeList.Keys) {
if($Scope -and $address -ne $Scope) { continue }
$dhcpScope = New-Object DHCPScope
$dhcpScope.Address = $address
$dhcpScope.Server = $Server.ToString()
$dhcpScope.SubnetMask = $scopeList[$address][0]
$dhcpScope.State = $scopeList[$address][1]
$dhcpScope.Name = $scopeList[$address][2]
$dhcpScope.Description = $scopeList[$address][3]
$dhcpScope.IPRanges = Get-DHCPIPRanges -Server $Server -Scope $address -Type "ipRange"
$dhcpScope.ExclusionRanges = Get-DHCPIPRanges -Server $Server -Scope $address -Type "excluderange"
$dhcpScope.Reservations = Get-DHCPReservation -Server $Server -Scope $address
$dhcpScope.LeasedIPs = Get-DHCPLeasedIps -Server $Server -Scope $address
$lease = Get-DHCPOption -Owner $dhcpScope -OptionID 51 -Force
$dhcpScope.Lease = if($lease){$lease.Values[0]}else{0}
$dhcpScope.Options = Get-DHCPOption -Owner $dhcpScope
$dhcpScope.DNSConfiguration = Get-DHCPDNSConfiguration -Owner $dhcpScope
$dhcpScopes += $dhcpScope
}
return $dhcpScopes
<#

Address : 10.214.15.128
SubnetMask : 255.255.255.128
Name : pdawireless
Description :
State : Disabled
Server : 10.214.15.12
IPRanges : {10.214.15.140 - 10.214.15.180}
ExclusionRanges :
Reservations :
Lease : 691200
Options : {Router, DNS Domain Name, DNS Servers}
DNSConfiguration : Inherited from Parent

Address : 10.214.15.0
SubnetMask : 255.255.255.128
Name : base
Description :
State : Active
Server : 10.214.15.12
IPRanges : {10.214.15.21 - 10.214.15.99}
ExclusionRanges :
Reservations :
Lease : 691200
Options : {Router, DNS Domain Name, DNS Servers}
DNSConfiguration : Inherited from Parent

#>
}

function Get-DHCPDNSConfiguration {
<#
.Synopsis
Retrieves the DNS update configuration for a given DHCP object.
.Example
Get-DHCPDNSConfiguration -Owner dhcp01.contoso.com/192.168.1.0/192.168.1.237
This example retrieves the DNS update configuration for the reservation 192.168.1.237 in the scope of 192.168.1.0 on server dhcp01.contoso.com.
.Description
The Get-DHCPDNSConfiguration cmdlet is used to retrieve the DNS update configuration for a given DHCP server, scope, or reservation. If no configuration is defined, then the configuration from its parent is inherited, except at the server level, which uses the default configuration.
.Parameter Owner
The value for this parameter can be a DHCPServer, DHCPScope, or DHCPReservation object. It can also be a string representation of these objects, defined thus:
ServerNameOrFQDN
ServerNameOrFQDN/ScopeAddress
ServerNameOrFQDN/ScopeAddress/ReservationAddress
.Outputs
DHCPDNSConfiguration
.Notes
Name: Get-DHCPDNSConfiguration
Module: Microsoft.DHCP.PowerShell.Admin.psm1
Author: Jeremy Engel
Date: 04.22.2011
#>
Param([Parameter(Mandatory = $true, ValueFromPipeline = $true)][PSObject]$Owner)
if($Owner.GetType() -eq [string]) {
switch($Owner.Split("/").Count) {
1 { $level = "Server" }
2 { $level = "Scope" }
3 { $level = "Reservation" }
default { return }
}
}
else { $level = $Owner.GetType().ToString().Substring(4) }
if(!($option = Get-DHCPOption -Owner $Owner -OptionID 81 -Force)) { return }
$value = [int]$option.Values[0]
$dnsConfig = New-Object DHCPDNSConfiguration
$dnsConfig.Level = $level
$dnsConfig.Value = $value
if($value -eq -1) {
if($level -ne "Server") {
if($Owner.GetType() -eq [string]) {
$parts = $Owner.Split("/")
$Owner = $parts[0..($parts.Count-2)] -Join "/"
}
elseif($Owner.GetType() -eq [DHCPReservation]) { $Owner = "$($Owner.Server)/$($Owner.Scope)" }
elseif($Owner.GetType() -eq [DHCPScope]) { $Owner = $Owner.Server }
else { return }
$dnsConfig = Get-DHCPDNSConfiguration -Owner $Owner
$dnsConfig.Level = $level
return $dnsConfig
}
else { $value = 5 }
}
if($value -ge 16) {
$dnsConfig.UpdateTrigger = "Always"
$value -= 16
}
else { $dnsConfig.UpdateTrigger = "ClientRequest" }
if($value -ge 4) {
$dnsConfig.DiscardStaleRecords = $true
$value -= 4
}
else { $dnsConfig.DiscardStaleRecords = $false }
if($value -ge 2) {
$dnsConfig.AllowLegacyClientUpdate = $true
$value -= 2
}
else { $dnsConfig.AllowLegacyClientUpdate = $false }
$dnsConfig.AllowDynamicUpdate = if($value -eq 1){$true}else{$false}
return $dnsConfig
}

function Get-DHCPIPRanges {
Param([Parameter(Mandatory = $false)][PSObject]$Server,
[Parameter(Mandatory = $true, ValueFromPipeline = $true)][PSObject]$Scope,
[Parameter(Mandatory = $true)][string]$Type
)
$ipranges = @()
if($Scope.GetType() -eq [DHCPScope] -and !$Server) { $Server = $Scope.Server }
$text = $(Invoke-Expression "cmd /c netsh dhcp server \\$Server scope $Scope show $Type")
$result = if($text.GetType() -eq [string]){$text}else{$text[($text.Count-1)]}
if($result.Contains("The command needs a valid Scope IP Address")) { Write-Host "ERROR: $Scope is not a valid scope on $Server." -ForeGroundColor Red; return }
if($result.Contains("Server may not function properly")) { Write-Host "ERROR: $Server is inaccessible or is not a DHCP server." -ForeGroundColor Red; return }
for($i=6;$i -lt $text.Count;$i++) {
if(!$text[$i]) { break }
$parts = $text[$i].Split("-") | %{ $_.Trim() }
$ipRange = New-Object DHCPIPRange
$ipRange.StartAddress = $parts[0]
$ipRange.EndAddress = $parts[1]
$ipRanges += $ipRange
}
return $ipRanges
}

function Get-DHCPOption {
<#
.Synopsis
Retrieves all or specific DHCP options and their values for a given level.
.Example
Get-DHCPOption -Owner dhcp01.contoso.com/192.168.1.0/192.168.1.237
This example retrieves all the options set for the reservation 192.168.1.237 in the scope of 192.168.1.0 on server dhcp01.contoso.com.
.Example
$scope | Get-DHCPOption -OptionID 3
Given that $scope is the DHCPScope object for subnet 192.168.1.0 on dhcp01.contoso.com, this examples retrieves scope option 3, the gateway address.
.Example
Get-DHCPOption -Owner $server -OptionID 81 -Force
Given that $server is the DHCPServer object for dhcp01.contoso.com, this example retrieves server option 81, dynamic dns configuration. For more information on why the -Force parameter was needed, please read its parameter
description under -full.
.Description
The Get-DHCPOption cmdlet is used to retrieve all or specific standard DHCP options and their values for a given server, scope, or reservation. Non-standard classes (eg: BOOTP) are not currently being recorded. The return value for success is one or an array of DHCPOption objects.
.Parameter Owner
The value for this parameter can be a DHCPServer, DHCPScope, or DHCPReservation object. It can also be a string representation of these objects, defined thus:
ServerNameOrFQDN
ServerNameOrFQDN/ScopeAddress
ServerNameOrFQDN/ScopeAddress/ReservationAddress
.Parameter OptionID
The value for this parameter must be the id of a valid DHCP option as listed by Get-DHCPOptionDefinitions.
.Parameter Force
This switch parameter is only needed if you want to retrieve options 51 (lease time in seconds) or 81 (int value for the dynamic dns configuration). These are otherwise not returned as their values are expressed elsewhere.
.Outputs
DHCPOption
.Notes
Name: Get-DHCPOption
Module: Microsoft.DHCP.PowerShell.Admin.psm1
Author: Jeremy Engel
Date: 12.16.2010
#>
Param([Parameter(Mandatory = $true, ValueFromPipeline = $true)][PSObject]$Owner,
[Parameter(Mandatory = $false)][int]$OptionID,
[Parameter(Mandatory = $false)][switch]$Force
)
$server = $null
$scope = $null
$reservation = $null
if($Owner.GetType() -eq [DHCPServer]) { $server = $Owner.Name }
elseif($Owner.GetType() -eq [DHCPScope]) {
$server = $Owner.Server
$scope = $Owner.Address
}
elseif($Owner.GetType() -eq [DHCPReservation]) {
$server = $Owner.Server
$scope = $Owner.Scope
$reservation = $Owner.IPAddress
}
else {
$parts = $Owner.ToString().Split("/")
$server = $parts[0]
if($parts.Count -gt 1) { $scope = $parts[1] }
if($parts.Count -gt 2) { $reservation = $parts[2] }
}
$command = if($scope){"\\$server scope $scope show optionvalue"}else{"\\$server show optionvalue"}
if($reservation) { $command = "\\$server scope $scope show reservedoptionvalue $reservation" }
$text = $(Invoke-Expression "cmd /c netsh dhcp server $command")
$result = if($text.GetType() -eq [string]){$text}else{$text[($text.Count-1)]}
if($result.Contains("Server may not function properly")) { Write-Host "ERROR: $server is inaccessible or is not a DHCP server." -ForeGroundColor Red; return }
if($result.Contains("The command needs a valid Scope IP Address")) { Write-Host "ERROR: $scope is not a valid scope on $server." -ForeGroundColor Red; return }
if($result.Contains("client is not a reserved")) { Write-Host "ERROR: $reservation is not a valid reservation in $scope on $server." -ForeGroundColor Red; return }
$options = @()
$work = @{}
$optiondefs = Get-DHCPOptionDefinitions -Server $server
$option = New-Object PSOBject
$option | Add-Member NoteProperty OptionName("DNS Configuration")
$option | Add-Member NoteProperty ArrayType("UNARY")
$option | Add-Member NoteProperty OptionType("DWORD")
$optiondefs.Add(81,$option)
$id = $null
$block = $false
for($i=0;$i -lt $text.Count;$i++) {
if($text[$i] -eq "Command completed successfully.") {
if(!!$id) {
$option = New-Object DHCPOption
$option.OptionID = $id
$option.OptionName = $optiondefs[$id].OptionName
$option.ArrayType = $optiondefs[$id].ArrayType
$option.OptionType = $optiondefs[$id].OptionType
$option.Values += $work[$optiondefs[$id].OptionName]
$option.Level = if($reservation){"Reservation"}elseif($scope){"Scope"}else{"Server"}
$options += $option
}
}
if($block) {
if($text[$i].Contains("DHCP Standard Options")) { $block = $false }
continue
}
if($text[$i].Contains("For vendor class") -or $text[$i].Contains("For user class")) { $block = $true; continue }
if($text[$i].Contains("OptionId")) {
if(!!$id) {
$option = New-Object DHCPOption
$option.OptionID = $id
$option.OptionName = $optiondefs[$id].OptionName
$option.ArrayType = $optiondefs[$id].ArrayType
$option.OptionType = $optiondefs[$id].OptionType
$option.Values += $work[$optiondefs[$id].OptionName]
$option.Level = if($reservation){"Reservation"}elseif($scope){"Scope"}else{"Server"}
$options += $option
}
$id = [int]($text[$i].Split(":")[1].Trim())
if($OptionID -and $OptionID -ne $id) { $id = $null; continue }
if(!$Force -and ($id -eq 81 -or $id -eq 51)) { $id = $null; continue }
$work.Add($optiondefs[$id].OptionName,$null)
}
elseif(!$id) { continue }
else {
if(!($text[$i].Contains("Option Element Value"))) { continue }
$desc = $optiondefs[$id].OptionName
$type = $optiondefs[$id].ArrayType
$values = $work[$desc]
$val = $text[$i].Split("=")[1].Trim()
if($type-eq"ARRAY") { $values += @($val) }
else { $values = $val }
$work[$desc] = $values
}
}
if($Force -and !($options | Where-Object { $_.OptionID -eq 81 }) -and $OptionID -eq 81) {
$id = 81
$option = New-Object DHCPOption
$option.OptionID = $id
$option.OptionName = $optiondefs[$id].OptionName
$option.ArrayType = $optiondefs[$id].ArrayType
$option.OptionType = $optiondefs[$id].OptionType
$option.Values += -1
$option.Level = if($reservation){"Reservation"}elseif($scope){"Scope"}else{"Server"}
$options += $option
}
return $options
}

function Get-DHCPOptionDefinitions {
<#
.Synopsis
Retrieves all DHCP options defined on a given server.
.Example
Get-DHCPOptionDefinitions -Server dhcp01.contoso.com
This example retrieves all the options defined on server dhcp01.contoso.com.
.Example
$server | Get-DHCPOptionDefinitions
Given that $server is the DHCPServer object for dhcp01.contoso.com, this example accomplishes the same as the one in Example 1.
.Description
The Get-DHCPOptionDefinitions cmdlet is used to retrieve all DHCP options defined on a given server.
.Parameter Server
The value for this parameter can be a DHCPServer object or the name or FQDN of the DHCP server. The designated server must by a valid DHCP server.
.Outputs
HashTable
.Notes
Name: Get-DHCPOptionDefinitions
Module: Microsoft.DHCP.PowerShell.Admin.psm1
Author: Jeremy Engel
Date: 12.16.2010
#>
Param([Parameter(Mandatory = $true, ValueFromPipeline = $true)][PSObject]$Server)
$options = @{}
$text = $(Invoke-Expression "cmd /c netsh dhcp server \\$Server show optiondef")
if($text[2].Contains("Server may not function properly")) { Write-Host "ERROR: $Server is inaccessible or is not a DHCP server." -ForeGroundColor Red; return }
for($i=7;$i -lt $text.Count;$i++) {
if(!$text[$i]) { break }
$parts = $text[$i].Split("-") | %{ $_.Trim() }
if($parts[2] -eq "to") {
$parts[1] = $parts[1]+"-"+$parts[2]+"-"+$parts[3]
$parts[2] = $parts[4]
$parts[3] = $parts[5]
}
$option = New-Object PSOBject
$option | Add-Member NoteProperty OptionName($parts[1])
$option | Add-Member NoteProperty ArrayType($parts[2])
$option | Add-Member NoteProperty OptionType($parts[3])
if($options.Keys -notcontains [int]$parts[0]) { $options.Add([int]$parts[0],$option) } #Needed if clause for some weird funkiness on Windows 2003 servers
}
return $options
}

function Get-DHCPReservation {
<#
.Synopsis
Retieves all or specific DHCP reservations for a given scope.
.Example
Get-DHCPReservation -Server dhcp01.contoso.com -Scope 192.168.1.0
This example retrieves all reservations in the 192.168.1.0 scope on dhcp01.contoso.com.
.Example
$scope | Get-DHCPReservation -IPAddress 192.168.1.237
Given that $scope is the DHCPScope object for subnet 192.168.1.0 on dhcp01.contoso.com, this example retrieves the 192.168.1.237 reservation.
.Description
The Get-DHCPReservation cmdlet is used to retieves all or specific DHCP reservations for a given scope. The return value for success is one or an array of DHCPReservation objects.
.Parameter Server
The value for this parameter can be a DHCPServer object or the name or FQDN of the DHCP server. The designated server must by a valid DHCP server.
.Parameter Scope
The value for this parameter can be a DHCPScope object or the subnet address of the scope. If entering the subnet address, the Server parameter must be defined and be the host of this scope.
.Parameter IPAddress
The value for this parameter must be in an IP address string format (ie: 0.0.0.0).
.Outputs
DHCPReservation
.Notes
Name: Get-DHCPReservation
Module: Microsoft.DHCP.PowerShell.Admin.psm1
Author: Jeremy Engel
Date: 12.16.2010
#>
Param([Parameter(Mandatory = $false)][PSObject]$Server,
[Parameter(Mandatory = $true, ValueFromPipeline = $true)][PSObject]$Scope,
[Parameter(Mandatory = $false)][string]$IPAddress
)
$reservations = @()
if($Scope.GetType() -eq [DHCPScope] -and !$Server) { $Server = $Scope.Server }
$text = $(Invoke-Expression "cmd /c netsh dhcp server \\$Server scope $Scope show reservedip")
$result = if($text.GetType() -eq [string]){$text}else{$text[($text.Count-1)]}
if($result.Contains("The command needs a valid Scope IP Address")) { Write-Host "ERROR: $Scope is not a valid scope on $Server." -ForeGroundColor Red; return }
if($result.Contains("Server may not function properly")) { Write-Host "ERROR: $Server is inaccessible or is not a DHCP server." -ForeGroundColor Red; return }
for($i=7;$i -lt $text.Count;$i++) {
if(!$text[$i]) { break }
$parts = $text[$i].Split("-") | %{ $_.Trim() }
if($IPAddress -and $parts[0] -ne $IPAddress) { continue }
$reservation = New-Object DHCPReservation
$reservation.IPAddress = $parts[0]
$reservation.MACAddress = [string]::Join("-",$parts[1..6])
$reservation.Scope = $Scope
$reservation.Server = $Server
$reservation.Options = Get-DHCPOption -Owner $reservation
$reservation.DNSConfiguration = Get-DHCPDNSConfiguration -Owner $reservation
$reservations += $reservation
}
return $reservations
}

function Get-DHCPLeasedIps {
<#
.Synopsis
Retieves all or specific DHCP leased IP lists for a given scope.
.Example
Get-DHCPReservation -Server dhcp01.contoso.com -Scope 192.168.1.0
This example retrieves all reservations in the 192.168.1.0 scope on dhcp01.contoso.com.
.Example
$scope | Get-DHCPReservation -IPAddress 192.168.1.237
Given that $scope is the DHCPScope object for subnet 192.168.1.0 on dhcp01.contoso.com, this example retrieves the 192.168.1.237 reservation.
.Description
The Get-DHCPReservation cmdlet is used to retieves all or specific DHCP reservations for a given scope. The return value for success is one or an array of DHCPReservation objects.
.Parameter Server
The value for this parameter can be a DHCPServer object or the name or FQDN of the DHCP server. The designated server must by a valid DHCP server.
.Parameter Scope
The value for this parameter can be a DHCPScope object or the subnet address of the scope. If entering the subnet address, the Server parameter must be defined and be the host of this scope.
.Parameter IPAddress
The value for this parameter must be in an IP address string format (ie: 0.0.0.0).
.Outputs
DHCPReservation
.Notes
Name: Get-DHCPReservation
Module: Microsoft.DHCP.PowerShell.Admin.psm1
Author: Jeremy Engel
Date: 12.16.2010
#>
Param([Parameter(Mandatory = $false)][PSObject]$Server,
[Parameter(Mandatory = $true, ValueFromPipeline = $true)][PSObject]$Scope,
[Parameter(Mandatory = $false)][string]$IPAddress
)
$leasedIPs = @()
if($Scope.GetType() -eq [DHCPScope] -and !$Server) { $Server = $Scope.Server }
$text = $(Invoke-Expression "cmd /c netsh dhcp server \\$Server scope $Scope show clients")
$result = if($text.GetType() -eq [string]){$text}else{$text[($text.Count-1)]}
if($result.Contains("The command needs a valid Scope IP Address")) { Write-Host "ERROR: $Scope is not a valid scope on $Server." -ForeGroundColor Red; return }
if($result.Contains("Server may not function properly")) { Write-Host "ERROR: $Server is inaccessible or is not a DHCP server." -ForeGroundColor Red; return }
for($i=8;$i -lt $text.Count;$i++) {
if(!$text[$i]) { break }
$parts = $text[$i].Split("-") | %{ $_.Trim() }
if($IPAddress -and $parts[0] -ne $IPAddress) { continue }
$leased = New-Object DHCPLeasedIp
$leased.IPAddress = $parts[0]
$leased.SubnetMask = $parts[1]
$leased.MACAddress = [string]::Join("-",$parts[2..7])
$leased.LeaseExpires = $parts[8]
$leased.Tip = $parts[9]
$leasedIPs += $leased
}
return $leasedIPs
}



$servers = Show-DHCPServers
$scopes = Get-DHCPScope -Server $servers[0].IPAddress
$rezervasyonlar = $scopes[0].Reservations
$cem = "Topkaya"

1 Mayıs 2011 Pazar

PowerShell script ile Netsh üzerinden OptionValue değerlerini öğrenmek

PS C:\hp\Debug> $(Invoke-Expression "cmd /c netsh dhcp server \\10.130.214.13 scope 10.214.102.0 show optionvalue")

Changed the current scope context to 10.214.102.0 scope.

Options for Scope 10.214.102.0:

DHCP Standard Options :
General Option Values:
OptionId : 15
Option Value:
Number of Option Elements = 1
Option Element Type = STRING
Option Element Value = fresenius.com.tr
OptionId : 51
Option Value:
Number of Option Elements = 1
Option Element Type = DWORD
Option Element Value = 691200
OptionId : 6
Option Value:
Number of Option Elements = 2
Option Element Type = IPADDRESS
Option Element Value = 10.130.214.13
Option Element Value = 10.130.214.12
OptionId : 3
Option Value:
Number of Option Elements = 1
Option Element Type = IPADDRESS
Option Element Value = 10.214.102.3
Command completed successfully.
PS C:\hp\Debug>

option value = 51 kiralama süresini saniye cinsinden verir.

PowerShell script ile Netsh'ı çağırmak ve kiralanmış IP adreslerini öğrenmek

Daha iyi powershell script için adres: http://gallery.technet.microsoft.com/scriptcenter/05b1d766-25a6-45cd-a0f1-8741ff6c04ec



PS C:\hp\Debuggt; $(Invoke-Expression "cmd /c netsh dhcp server \\10.130.214.13 scope 10.214.102.0 show clients")

Changed the current scope context to 10.214.102.0 scope.

Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP
==================================================================================
IP Address - Subnet Mask - Unique ID - Lease Expires -Type
==================================================================================

10.214.102.20 - 255.255.255.0 - 00-1c-bf-b7-d3-b8 -07.05.2011 17:54:59 -D
10.214.102.21 - 255.255.255.0 - 00-21-6b-61-19-fe -07.05.2011 14:45:01 -D
10.214.102.22 - 255.255.255.0 - 00-21-6b-5f-9e-72 -07.05.2011 11:51:58 -D
10.214.102.23 - 255.255.255.0 - 00-21-6b-1d-6a-5c -07.05.2011 18:28:48 -D
10.214.102.24 - 255.255.255.0 - ac-81-12-26-57-06 -07.05.2011 13:57:07 -D
10.214.102.25 - 255.255.255.0 -ac-81-12-1b-9f-59 - NEVER EXPIRES -U
10.214.102.26 - 255.255.255.0 - 00-21-6b-5f-c5-3c -08.05.2011 20:12:02 -D
10.214.102.27 - 255.255.255.0 - 00-22-fa-ee-00-58 -07.05.2011 18:44:30 -D
10.214.102.28 - 255.255.255.0 - 00-26-82-56-95-78 -08.05.2011 11:29:41 -D
10.214.102.30 - 255.255.255.0 - 00-27-10-24-81-b4 -05.05.2011 14:46:26 -D
10.214.102.31 - 255.255.255.0 - 58-94-6b-87-22-98 -07.05.2011 12:38:43 -D
10.214.102.32 - 255.255.255.0 - 00-26-c6-59-c0-22 -07.05.2011 22:04:10 -D
10.214.102.33 - 255.255.255.0 - ac-81-12-0b-57-75 -07.05.2011 08:29:14 -D

DHCP Lease (IP Kiralama) süresini öğrenme ve değiştirme


netsh dhcp server scope>help
list - Lists all the commands available.
dump - Dumps scope configuration to a text file.
help - Displays help.
? - Displays help.
add - Adds a configuration entry to a table.
delete - Deletes a configuration entry from a table.
initiate - Initiates an operation.
set - Sets configuration information.
show - Displays information.

netsh dhcp server scope>show optionvalue 51

Options for Scope 10.214.102.0:

DHCP Standard Options :
General Option Values:
OptionId : 15
Option Value:
Number of Option Elements = 1
Option Element Type = STRING
Option Element Value = fresenius.com.tr
OptionId : 51
Option Value:
Number of Option Elements = 1
Option Element Type = DWORD
Option Element Value = 691200
OptionId : 6
Option Value:
Number of Option Elements = 2
Option Element Type = IPADDRESS
Option Element Value = 10.130.214.13
Option Element Value = 10.130.214.12
OptionId : 3
Option Value:
Number of Option Elements = 1
Option Element Type = IPADDRESS
Option Element Value = 10.214.102.3
Command completed successfully.
// 51 bizim dhcp lease süresi. bu değeri değiştirmek için aşağıdaki gibi yazarız
netsh dhcp server scope>set optionvalue 51 DWORD 3600

691200 değeri = 8 gün = 8 x 24 saat = 8 x 24 x 3600(saniye)

Netsh ile DHCP den bilgi çekmek

Tabi cmd yi çalıştırırken "runas Administrator" olursa daha iyi olur.

c:\Netsh (Enter)
netsh>dhcp (Enter)
netsh dhcp>server (Enter)
netsh dhcp server>show server(Enter)


netsh dhcp server server> show scope(Enter)

netsh dhcp server server>scope 10.214.102.0 (Enter)

netsh dhcp server server scope> show clients (Enter)