DHCP Sunucusundan IP Silme
IP bloklarının verebildiği IP adres sayılarının yetersiz olduğu durumda bazı IP adreslerinin DHCP’den silinmesi gerekmektedir. Adresleri tek tek silinebileceği gibi bir powershell scripti ile toplu da silinebilir. Aşağıda yer alan powershell scriprti kullanılarak belli şartları şağlayan IP adreslerini kolaylıkla silebiliriz. Script active directory kullanıcısnın yetkisye sahip olması durumunda kendi bilgisayarında da çalıştırabilir.
Aşağıdaki örnek scripte isminde android, galaxy veya phone geçen ve rezerve olmayan IP adresleri siliniyor.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
$message = New-Object -ComObject wscript.shell $dhcpServer = Read-Host "Dhcp IP Adresi Giriniz" $scopeId = Read-Host "Temizlenecek Scope IP Adresi Giriniz" $ipList = Get-DhcpServerv4Lease -ComputerName $dhcpServer -ScopeId $scopeId | where {( $_ .HostName -like 'android*' -or $_ .HostName -like '*phone*' -or $_ .HostName -like '*galaxy*' ) -and $_ .AddressState -NOTlike '*Reservation*' } Write-Host "Silinecek IP Sayıları" Write-Host "Android Sayısı: " + ( $ipList | where { $_ .HostName -like 'android*' -or $_ .HostName -like '*galaxy*' }).Count Write-Host "IPhone Sayısı: " + ( $ipList | where { $_ .HostName -like '*phone*' }).Count Write-Host "Toplam: " + $ipList .Count $confirm = $message .popup( "IP adresleri DHCP üzerinden silinecektir. Onaylıyor musunuz?" ,0 , "IP Adresini Sil" , 4) if ( $confirm -eq 6) { $ipList | Remove-DhcpServerv4Lease -ComputerName $dhcpServer $message .Popup( "IP adresleri silinmiştir." , 0, "Bilgi" , 0) } |