Hack x Crack - Comunidad de Seguridad informática
Programación => Scripting => Batch / Bash => Mensaje iniciado por: fe80Grau en Septiembre 03, 2014, 12:39:25 am
Título:
[Powershell] Pequeña función para comprobar si un dominio tiene registros MX
Publicado por:
fe80Grau
en
Septiembre 03, 2014, 12:39:25 am
Comparto esta sencilla función que podéis implementar en vuestros scripts en PowerShell para comprobar si existe algún registro MX en un dominio.
Código: PowerShell
function
compE
{
param
(
[
String
]
$dominio
)
;
$existe
=
0
;
$cont
=
0
;
Invoke-Expression
-Command
"nslookup -type=mx $dominio"
2
>
$null
|
foreach-object
{
$filas
=
$
(
$_
)
;
$filtrar
=
$filas
-match
'mail exchanger'
;
if
(
$filtrar
)
{
$cont
++
;
}
}
if
(
$cont
-ge
1
)
{
$existe
=
1
;
}
else
{
$existe
=
0
;
}
return
$existe
;
}