성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
[정성태] 저렇게 조각 코드 말고, 실제로 재현이 되는 예제 프로젝트를 압...
[정성태] Modules 창(Ctrl+Shift+U)을 띄워서, 해당 Op...
[정성태] 만드실 수 있습니다. 단지, Unity 엔진 내의 스크립트와 W...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>PowerShell - Zone 별로 DNS 레코드 유형 정보 조회</h1> <p> 아래와 같은 글이 있군요. ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Extract DNS Records to CSV with PowerShell ; <a target='tab' href='https://chentiangemalc.wordpress.com/2018/10/17/extract-dns-records-to-csv-with-powershell/'>https://chentiangemalc.wordpress.com/2018/10/17/extract-dns-records-to-csv-with-powershell/</a> </pre> <br /> github를 통해 공개한 스크립트를 보면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Get-AllDnsResourceRecords.ps1 ; <a target='tab' href='https://github.com/chentiangemalc/PowerShellScripts/blob/master/Get-AllDnsResourceRecords.ps1'>https://github.com/chentiangemalc/PowerShellScripts/blob/master/Get-AllDnsResourceRecords.ps1</a> </pre> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > [CmdletBinding()] param( [Parameter(Position=0)] [String]$DNSServer) $Zones = @(Get-DnsServerZone -ComputerName $DNSServer) $Data = @() ForEach ($Zone in $Zones) { ($Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer) | ` Select-Object -Property ` @{Label="Zone Name";expression={( $Zone.ZoneName )}},` DistinguishedName,` HostName,` RecordClass,` RecordType,` Timestamp,` TimeToLive,` @{label="Data";expression={ $r = $_.RecordData switch ($_.RecordType) { "A" { $r.IPv4Address.IPAddressToString } "NS" { $r.NameServer } "SOA" { "ExpireLimit=$($r.ExpireLimit);"+ "MinimumTimeToLive=$($r.MinimumTimeToLive);"+ "PrimaryServer=$($r.PrimaryServer);"+ "RefreshInterval=$($r.RefreshInterval);"+ "ResponsiblePerson=$($r.ResponsiblePerson);"+ "RetryDelay=$($r.RetryDelay);"+ "SerialNumber=$($r.SerialNumber)" } "CNAME" { $r.HostNameAlias } "SRV"{ "DomainName=$($r.DomainName);"+ "Port=$($r.Port);"+ "Priority=$($r.Priority);"+ "Weight=$($r.Weight)" } "AAAA" { $r.IPv6Address.IPAddressToString } "PTR" { $r.PtrDomainName } "MX" { "MailExchange=$($r.MailExchange);"+ "Prefreence=$($r.Preference)" } "TXT" { $r.DescriptiveText } Default { "Unsupported Record Type" } }} } } </pre> <br /> 다운로드해 다음과 같이 실행할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > & "c:\temp\ps_dns.ps1" -DnsServer 8.8.8.8 </pre> <br /> 그런데 실제로 실행해 보면 이런 오류가 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > PS C:\temp> & "C:\temp\ps_dns.ps1" -DnsServer 8.8.8.8 Get-DnsServerZone : Failed to enumerate zones from the server 8.8.8.8. At C:\temp\ps_dns.ps1:44 char:12 + $Zones = @(Get-DnsServerZone -ComputerName $DNSServer) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (8.8.8.8:root/Microsoft/...S_DnsServerZone) [Get-DnsServerZone], CimException + FullyQualifiedErrorId : WIN32 1722,Get-DnsServerZone </pre> <br /> Win32 에러 코드가 1722면 "The RPC server is unavailable"입니다. 그러니까, 해당 글의 예제와는 달리 구글 쪽의 DNS 서버 조회는 할 수 없는 것입니다. (실제로 에러 메시지를 보면 "8.8.8.8:root/Microsoft/...S_DnsServerZone"이라는 마이크로소프트 쪽 Namespace 정보가 나옵니다.)<br /> <br /> 따라서 위의 명령은 Microsoft DNS 서버의 정보를 알아내는데 사용할 수 있습니다. 아래는 그에 대한 출력 예제입니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > PS C:\Users> $ScriptBlockContent = { $myArg = 'mydnsserver' C:\temp\ps_dns.ps1 -DNSServer $myArg } PS C:\Users> Invoke-Command -ScriptBlock $ScriptBlockContent Zone Name : _msdcs.testad.com DistinguishedName : DC=@,DC=_msdcs.testad.com,cn=MicrosoftDNS,DC=ForestDnsZones,DC=testad,DC=com HostName : @ RecordClass : IN RecordType : NS Timestamp : TimeToLive : 01:00:00 Data : testpdc.testad.com. Zone Name : _msdcs.testad.com DistinguishedName : DC=@,DC=_msdcs.testad.com,cn=MicrosoftDNS,DC=ForestDnsZones,DC=testad,DC=com HostName : @ RecordClass : IN RecordType : NS Timestamp : TimeToLive : 01:00:00 Data : testpdc4.testad.com. ...[생략]... Zone Name : testad.com DistinguishedName : DC=@,DC=testad.com,cn=MicrosoftDNS,DC=DomainDnsZones,DC=testad,DC=com HostName : @ RecordClass : IN RecordType : NS Timestamp : TimeToLive : 01:00:00 Data : testpdc4.testad.com. Zone Name : testad.com DistinguishedName : DC=@,DC=testad.com,cn=MicrosoftDNS,DC=DomainDnsZones,DC=testad,DC=com HostName : @ RecordClass : IN RecordType : NS Timestamp : TimeToLive : 01:00:00 Data : testpdc.testad.com. ...[생략]... </pre> <br /> <hr style='width: 50%' /><br /> <br /> 참고로, 본문의 스크립트에서 사용한 Get-DnsServerZone 명령어 자체가 실행이 안 되는 경우가 많을 것입니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > PS C:\Users> <span style='color: blue; font-weight: bold'>Get-DnsServerZone</span> Get-DnsServerZone : The term 'Get-DnsServerZone' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-DnsServerZone + ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-DnsServerZone:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException </pre> <br /> 이런 경우, dnsserver 모듈을 import 해 보면 다음과 같은 결과가 나옵니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > PS C:\Users> Import-Module dnsserver Import-Module : The specified module 'dnsserver' was not loaded because no valid module file was found in any module directory. At line:1 char:1 + Import-Module dnsserver + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (dnsserver:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand </pre> <br /> "<a target='tab' href='https://chentiangemalc.wordpress.com/2018/10/17/extract-dns-records-to-csv-with-powershell/'>Extract DNS Records to CSV with PowerShell</a>" 글의 덧글에 보면 Windows 10과 Server 2016에 내장되어 있다고 하는데 실제로는 DNS 관련 구성 요소가 설치된 경우에만 유효합니다. 설치 방법은, 다음과 같이 "Add Roles and Features Wizard"에서 "Remote Server Administration Tools" / "Role AdministrationTools" 범주에 있는 "DNS Server Tools"를 선택, 설치하면 됩니다. <br /> <br /> <img onclick='toggle_img(this)' class='imgView' alt='dns_server_tools_1.png' src='/SysWebRes/bbs/dns_server_tools_1.png' /><br /> <br /> 참고로 윈도우 10에는 이에 해당하는 구성 요소가 없습니다. 대신 별도로 다음의 링크에서 다운로드할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Remote Server Administration Tools for Windows 10 ; <a target='tab' href='https://www.microsoft.com/en-us/download/details.aspx?id=45520'>https://www.microsoft.com/en-us/download/details.aspx?id=45520</a> </pre> <br /> 주의할 것은, 위의 링크에서 제공하는 RSAT은 Windows 10의 1709, 1803 버전 용입니다. 이번에 릴리스한 1807 버전의 경우 다음의 경고문에 써진 것처럼,<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> IMPORTANT: Starting with Windows 10 October 2018 Update, RSAT is included as a set of "Features on Demand" in Windows 10 itself. See "Install Instructions" below for details, and "Additional Information" for recommendations and troubleshooting. RSAT lets IT admins manage Windows Server roles and features from a Windows 10 PC. <br /> </div><br /> <br /> "Settings" / "Apps & features" / "Manage optional features" 패널에서 "Add a feature" 버튼을 통해 다음과 같이 개별 RSAT 구성 요소를 설치할 수 있습니다.<br /> <br /> <img alt='dns_server_tools_2.png' src='/SysWebRes/bbs/dns_server_tools_2.png' /><br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1561
(왼쪽의 숫자를 입력해야 합니다.)