$file=Get-content 'C:\temp\ipsviejas.txt' foreach ($ip in $file) { write-host ($ip+':') Get-WmiObject -Namespace Root\MicrosoftDNS -Query "SELECT * FROM MicrosoftDNS_AType WHERE RecordData='$ip'" -Computer 'SERVERDNS.contoso.com' | select OwnerName -expandproperty OwnerName }
Obtener Registros host A apuntando a una determinada IP
Started by Alberto Dominguez, sep 23 2014 16:58
No replies to this topic
#1
Escrito 23 septiembre 2014 - 16:58
Saludos,
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
#2
Escrito 26 septiembre 2014 - 08:59
$file=Get-content 'C:\temp\dnsips\ips.txt' foreach ($ip in $file) { $hosts=Get-WmiObject -Namespace Root\MicrosoftDNS -Query "SELECT * FROM MicrosoftDNS_AType WHERE RecordData='$ip'" -Computer 'localhost' | select OwnerName -expandproperty OwnerName foreach ($item in $hosts) { write-host ($ip+';'+$item) write-output ($ip+';'+$item) } }
Saludos,
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
#3
Escrito 26 septiembre 2014 - 09:48
Incluyendo la verificación también de CNAMEs que apuntan a Host A que apuntan a la IP indicada:
$computer='localhost' $file=Get-content 'C:\temp\dnsips\ips.txt' foreach ($ip in $file) { $hosts=Get-WmiObject -Namespace Root\MicrosoftDNS -Query "SELECT * FROM MicrosoftDNS_AType WHERE RecordData='$ip'" -Computer $computer | select OwnerName -expandproperty OwnerName foreach ($item in $hosts) { $itemAux=$item+'.' $CNAMEs=Get-WmiObject -Namespace Root\MicrosoftDNS -Query "SELECT * FROM MicrosoftDNS_CNAMEType WHERE RecordData='$itemAux'" -Computer $computer | select OwnerName -expandproperty OwnerName if ($CNAMEs -ne $null) { foreach ($item2 in $CNAMEs) { write-host ($ip+';'+$item+';'+$item2) write-output ($ip+';'+$item+';'+$item2) } } else { write-host ($ip+';'+$item) write-output ($ip+';'+$item) } } }
Saludos,
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
0 usuarios están leyendo este tema
0 miembro/s, 0 invitado/s, 0 usuario/s anónimo/s