Set-DNSPTRRecord: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<source lang="powershell"> Function Set-DNSPTRRecord { [CmdletBinding()] #$ErrorActionPreference = "SilentlyContinue" param ( [Parame…“) |
Admin (Diskussion | Beiträge) |
||
(Eine dazwischenliegende Version des gleichen Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
+ | <span style="font-size:20px;"><span style="color:red">'''-> This function/script is moved to [https://github.com/R-Studio/PSTools GitHub]!'''</span></span><br> | ||
+ | |||
<source lang="powershell"> | <source lang="powershell"> | ||
Function Set-DNSPTRRecord { | Function Set-DNSPTRRecord { | ||
Zeile 13: | Zeile 15: | ||
process { | process { | ||
$DomainController = Get-ADDomainController | select -ExpandProperty Name | $DomainController = Get-ADDomainController | select -ExpandProperty Name | ||
− | $Records = Get-DnsServerResourceRecord -ComputerName $DomainController -ZoneName $ForwardZone -RRType A | where {$_.HostName -notlike "*DnsZones*" -and $_.HostName -notlike "*@* | + | $Records = Get-DnsServerResourceRecord -ComputerName $DomainController -ZoneName $ForwardZone -RRType A | where {$_.HostName -notlike "*DnsZones*" -and $_.HostName -notlike "*@*"} | Select RecordData,Hostname |
foreach ($Record in $Records) { | foreach ($Record in $Records) { |
Aktuelle Version vom 26. Februar 2020, 10:52 Uhr
-> This function/script is moved to GitHub!
Function Set-DNSPTRRecord { [CmdletBinding()] #$ErrorActionPreference = "SilentlyContinue" param ( [Parameter(Position=0,mandatory=$true,HelpMessage="Type Forward lookup zone name in format - DOMAIN.NAME")] [string]$ForwardZone, [Parameter(Position=1,mandatory=$true,HelpMessage="Reverse lookup zone name in format - 1.16.172.in-addr.arpa")] [string]$ReverseZone ) process { $DomainController = Get-ADDomainController | select -ExpandProperty Name $Records = Get-DnsServerResourceRecord -ComputerName $DomainController -ZoneName $ForwardZone -RRType A | where {$_.HostName -notlike "*DnsZones*" -and $_.HostName -notlike "*@*"} | Select RecordData,Hostname foreach ($Record in $Records) { $Domain = ($env:USERDNSDOMAIN.ToString().ToLower()) $IPAddress = $($Record.RecordData.IPv4Address).ToString() $SplitedIP = $IPAddress.Split(".")[3] $IPstring = $SplitedIP.ToString() $HostName = $($Record.HostName).ToString() $FQDN = "$HostName."+"$Domain" Add-DnsServerResourceRecordPtr -Name $IPstring -ZoneName $ReverseZone -AllowUpdateAny -TimeToLive 01:00:00 -AgeRecord -PtrDomainName $FQDN -ComputerName $DomainController } } }
More Informations: https://gallery.technet.microsoft.com/scriptcenter/Update-DNS-PTR-Records-61d8435b