Actualiser Active Directory/Active Directory Health Check/ADHealthCheck.ps1
This commit is contained in:
parent
f35793840a
commit
cfd2d3391e
@ -1,8 +1,8 @@
|
|||||||
<#PSScriptInfo
|
<#PSScriptInfo
|
||||||
.VERSION 1.0
|
.VERSION 1.2
|
||||||
.GUID 30c7c087-1268-4d21-8bf7-ee25c37459b0
|
.GUID
|
||||||
.AUTHOR Vikas Sukhija
|
.AUTHOR Hubert Cornet
|
||||||
.COMPANYNAME TechWizard.cloud
|
.COMPANYNAME
|
||||||
.COPYRIGHT
|
.COPYRIGHT
|
||||||
.TAGS
|
.TAGS
|
||||||
.LICENSEURI
|
.LICENSEURI
|
||||||
@ -26,335 +26,334 @@
|
|||||||
param (
|
param (
|
||||||
[string]$Smtphost = $(Read-Host "Entrer l'addresse du serveur SMTP : "),
|
[string]$Smtphost = $(Read-Host "Entrer l'addresse du serveur SMTP : "),
|
||||||
[string]$from = $(Read-Host "Entrer l'adresse mail de l'expéditeur : "),
|
[string]$from = $(Read-Host "Entrer l'adresse mail de l'expéditeur : "),
|
||||||
[String[]]$EmailReport = $(Read-Host "Entrer l'adresse mail du ou des destinataire(s) (séparés par une virgule) pour recevoir le rapport"),
|
[String[]]$MailReport = $(Read-Host "Entrer l'adresse mail du ou des destinataire(s) (séparés par une virgule) pour recevoir le rapport"),
|
||||||
$timeout = "60"
|
$timeout = "120"
|
||||||
)
|
)
|
||||||
|
|
||||||
###########################Define Variables##################################
|
###########################Define Variables##################################
|
||||||
$EmailReport = $EmailReport -split ','
|
$MailReport = $MailReport -split ','
|
||||||
$report = ".\ADReport.htm"
|
$Report = ".\AD-Report.htm"
|
||||||
|
|
||||||
if((test-path $report) -like $false)
|
If ((test-path $Report) -like $False) {
|
||||||
{
|
new-item $Report -type File
|
||||||
new-item $report -type file
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################Get ALL DC Servers#######################
|
#####################################Get ALL DC Servers#######################
|
||||||
$getForest = [system.directoryservices.activedirectory.Forest]::GetCurrentForest()
|
$GetForest = [system.directoryservices.activedirectory.Forest]::GetCurrentForest()
|
||||||
$DCServers = $getForest.domains | ForEach-Object {$_.DomainControllers} | ForEach-Object {$_.Name}
|
$DCServers = $getForest.domains | ForEach-Object {$_.DomainControllers} | ForEach-Object {$_.Name}
|
||||||
|
|
||||||
###############################HTml Report Content############################
|
###############################HTml Report Content############################
|
||||||
Clear-Content $report
|
Clear-Content $Report
|
||||||
|
|
||||||
Add-Content $report "<html>"
|
Add-Content $Report "<html>"
|
||||||
Add-Content $report "<head>"
|
Add-Content $Report " <head>"
|
||||||
Add-Content $report "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
|
Add-Content $Report " <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
|
||||||
Add-Content $report '<title>AD Status Report</title>'
|
Add-Content $Report ' <title> Rapport Status Active Directory </title>'
|
||||||
add-content $report '<STYLE TYPE="text/css">'
|
Add-Content $Report ' <STYLE TYPE="text/css">'
|
||||||
add-content $report "<!--"
|
Add-Content $Report " <!--"
|
||||||
add-content $report "td {"
|
Add-Content $Report " td {"
|
||||||
add-content $report "font-family: Tahoma;"
|
Add-Content $Report " font-family: Tahoma;"
|
||||||
add-content $report "font-size: 11px;"
|
Add-Content $Report " font-size: 11px;"
|
||||||
add-content $report "border-top: 1px solid #999999;"
|
Add-Content $Report " border-top: 1px solid #999999;"
|
||||||
add-content $report "border-right: 1px solid #999999;"
|
Add-Content $Report " border-right: 1px solid #999999;"
|
||||||
add-content $report "border-bottom: 1px solid #999999;"
|
Add-Content $Report " border-bottom: 1px solid #999999;"
|
||||||
add-content $report "border-left: 1px solid #999999;"
|
Add-Content $Report " border-left: 1px solid #999999;"
|
||||||
add-content $report "padding-top: 0px;"
|
Add-Content $Report " padding-top: 0px;"
|
||||||
add-content $report "padding-right: 0px;"
|
Add-Content $Report " padding-right: 0px;"
|
||||||
add-content $report "padding-bottom: 0px;"
|
Add-Content $Report " padding-bottom: 0px;"
|
||||||
add-content $report "padding-left: 0px;"
|
Add-Content $Report " padding-left: 0px;"
|
||||||
add-content $report "}"
|
Add-Content $Report " }"
|
||||||
add-content $report "body {"
|
Add-Content $Report " body {"
|
||||||
add-content $report "margin-left: 5px;"
|
Add-Content $Report " margin-left: 5px;"
|
||||||
add-content $report "margin-top: 5px;"
|
Add-Content $Report " margin-top: 5px;"
|
||||||
add-content $report "margin-right: 0px;"
|
Add-Content $Report " margin-right: 0px;"
|
||||||
add-content $report "margin-bottom: 10px;"
|
Add-Content $Report " margin-bottom: 10px;"
|
||||||
add-content $report ""
|
Add-Content $Report " }"
|
||||||
add-content $report "table {"
|
Add-Content $Report " table {"
|
||||||
add-content $report "border: thin solid #000000;"
|
Add-Content $Report " border: thin solid #000000;"
|
||||||
add-content $report "}"
|
Add-Content $Report " }"
|
||||||
add-content $report "-->"
|
Add-Content $Report " -->"
|
||||||
add-content $report "</style>"
|
Add-Content $Report " </style>"
|
||||||
Add-Content $report "</head>"
|
Add-Content $Report " </head>"
|
||||||
Add-Content $report "<body>"
|
Add-Content $Report " <body>"
|
||||||
add-content $report "<table width='100%'>"
|
Add-Content $Report " <table width='100%'>"
|
||||||
add-content $report "<tr bgcolor='Lavender'>"
|
Add-Content $Report " <tr bgcolor='Lavender'>"
|
||||||
add-content $report "<td colspan='7' height='25' align='center'>"
|
Add-Content $Report " <td colspan='7' height='25' align='center'>"
|
||||||
add-content $report "<font face='tahoma' color='#003399' size='4'><strong>Active Directory Health Check</strong></font>"
|
Add-Content $Report " <font face='tahoma' color='#003399' size='4'><strong> Active Directory Check Health </strong></font>"
|
||||||
add-content $report "</td>"
|
Add-Content $Report " </td>"
|
||||||
add-content $report "</tr>"
|
Add-Content $Report " </tr>"
|
||||||
add-content $report "</table>"
|
Add-Content $Report " </table>"
|
||||||
|
|
||||||
add-content $report "<table width='100%'>"
|
Add-Content $Report " <table width='100%'>"
|
||||||
Add-Content $report "<tr bgcolor='IndianRed'>"
|
Add-Content $Report " <tr bgcolor='IndianRed'>"
|
||||||
Add-Content $report "<td width='5%' align='center'><B>Identity</B></td>"
|
Add-Content $Report " <td width='5%' align='center'><B> Identite </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>PingSTatus</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Status du ping </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>NetlogonService</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Service Netlogon </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>NTDSService</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Service NTDS </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>DNSServiceStatus</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Status Service DNS </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>NetlogonsTest</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Test Netlogons </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>ReplicationTest</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Test Replication </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>ServicesTest</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Test Services </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>AdvertisingTest</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Test Advertising </B></td>"
|
||||||
Add-Content $report "<td width='10%' align='center'><B>FSMOCheckTest</B></td>"
|
Add-Content $Report " <td width='10%' align='center'><B> Test Check FSMO </B></td>"
|
||||||
|
Add-Content $Report " </tr>"
|
||||||
Add-Content $report "</tr>"
|
|
||||||
|
|
||||||
################Ping Test################################################################
|
################Ping Test################################################################
|
||||||
Foreach ($DC in $DCServers){
|
Foreach ($DC in $DCServers) {
|
||||||
$Identity = $DC
|
$Identity = $DC
|
||||||
Add-Content $report "<tr>"
|
Add-Content $Report " <tr>"
|
||||||
If ( Test-Connection -ComputerName $DC -Count 1 -ErrorAction SilentlyContinue ) {
|
|
||||||
Write-Host $DC `t $DC `t Ping Success -ForegroundColor Green
|
If ( Test-Connection -ComputerName $DC -Count 1 -ErrorAction SilentlyContinue ) {
|
||||||
|
Write-Host $DC `t $DC `t Ping Success -ForegroundColor Green
|
||||||
|
|
||||||
Add-Content $report "<td bgcolor= 'GainsBoro' align=center> <B> $Identity</B></td>"
|
Add-Content $Report " <td bgcolor= 'GainsBoro' align=center><B> $Identity </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center> <B>Success</B></td>"
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> OkK </B></td>"
|
||||||
|
|
||||||
##############Netlogon Service Status################
|
##############Netlogon Service Status################
|
||||||
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "Netlogon" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "Netlogon" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
||||||
wait-job $serviceStatus -timeout $timeout
|
Wait-Job $serviceStatus -timeout $timeout
|
||||||
if($serviceStatus.state -like "Running")
|
|
||||||
{
|
If ($serviceStatus.state -like "Running") {
|
||||||
Write-Host $DC `t Netlogon Service TimeOut -ForegroundColor Yellow
|
Write-Host $DC `t Netlogon Service TimeOut -ForegroundColor Yellow
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>NetlogonTimeout</B></td>"
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Netlogon </B></td>"
|
||||||
stop-job $serviceStatus
|
Stop-Job $serviceStatus
|
||||||
}
|
}
|
||||||
else
|
Else {
|
||||||
{
|
$serviceStatus1 = Receive-job $serviceStatus
|
||||||
$serviceStatus1 = Receive-job $serviceStatus
|
If ($serviceStatus1.status -eq "Running") {
|
||||||
if ($serviceStatus1.status -eq "Running") {
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
||||||
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
|
||||||
$svcName = $serviceStatus1.name
|
$svcName = $serviceStatus1.name
|
||||||
$svcState = $serviceStatus1.status
|
$svcState = $serviceStatus1.status
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>$svcState</B></td>"
|
|
||||||
}
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> $svcState </B></td>"
|
||||||
else
|
}
|
||||||
{
|
Else {
|
||||||
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
||||||
$svcName = $serviceStatus1.name
|
|
||||||
$svcState = $serviceStatus1.status
|
$svcName = $serviceStatus1.name
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>$svcState</B></td>"
|
$svcState = $serviceStatus1.status
|
||||||
}
|
|
||||||
}
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> $svcState </B></td>"
|
||||||
######################################################
|
}
|
||||||
##############NTDS Service Status################
|
}
|
||||||
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "NTDS" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
|
||||||
wait-job $serviceStatus -timeout $timeout
|
##############NTDS Service Status################
|
||||||
if($serviceStatus.state -like "Running")
|
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "NTDS" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
||||||
{
|
Wait-Job $serviceStatus -timeout $timeout
|
||||||
Write-Host $DC `t NTDS Service TimeOut -ForegroundColor Yellow
|
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>NTDSTimeout</B></td>"
|
If ($serviceStatus.state -like "Running") {
|
||||||
stop-job $serviceStatus
|
Write-Host $DC `t NTDS Service TimeOut -ForegroundColor Yellow
|
||||||
}
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout NTDS </B></td>"
|
||||||
else
|
Stop-Job $serviceStatus
|
||||||
{
|
}
|
||||||
$serviceStatus1 = Receive-job $serviceStatus
|
Else {
|
||||||
if ($serviceStatus1.status -eq "Running") {
|
$serviceStatus1 = Receive-job $serviceStatus
|
||||||
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
|
||||||
$svcName = $serviceStatus1.name
|
If ($serviceStatus1.status -eq "Running") {
|
||||||
$svcState = $serviceStatus1.status
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>$svcState</B></td>"
|
|
||||||
}
|
$svcName = $serviceStatus1.name
|
||||||
else
|
$svcState = $serviceStatus1.status
|
||||||
{
|
|
||||||
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> $svcState </B></td>"
|
||||||
$svcName = $serviceStatus1.name
|
}
|
||||||
$svcState = $serviceStatus1.status
|
Else {
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>$svcState</B></td>"
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
||||||
}
|
|
||||||
}
|
$svcName = $serviceStatus1.name
|
||||||
######################################################
|
$svcState = $serviceStatus1.status
|
||||||
##############DNS Service Status################
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> $svcState </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##############DNS Service Status################
|
||||||
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "DNS" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "DNS" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
||||||
wait-job $serviceStatus -timeout $timeout
|
|
||||||
if($serviceStatus.state -like "Running")
|
Wait-Job $serviceStatus -timeout $timeout
|
||||||
{
|
|
||||||
Write-Host $DC `t DNS Server Service TimeOut -ForegroundColor Yellow
|
If ($serviceStatus.state -like "Running") {
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>DNSTimeout</B></td>"
|
Write-Host $DC `t DNS Server Service TimeOut -ForegroundColor Yellow
|
||||||
stop-job $serviceStatus
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout DNS </B></td>"
|
||||||
}
|
Stop-Job $serviceStatus
|
||||||
else
|
}
|
||||||
{
|
Else {
|
||||||
$serviceStatus1 = Receive-job $serviceStatus
|
$serviceStatus1 = Receive-job $serviceStatus
|
||||||
if ($serviceStatus1.status -eq "Running") {
|
|
||||||
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
If ($serviceStatus1.status -eq "Running") {
|
||||||
$svcName = $serviceStatus1.name
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
||||||
$svcState = $serviceStatus1.status
|
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>$svcState</B></td>"
|
$svcName = $serviceStatus1.name
|
||||||
}
|
$svcState = $serviceStatus1.status
|
||||||
else
|
|
||||||
{
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> $svcState </B></td>"
|
||||||
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
}
|
||||||
$svcName = $serviceStatus1.name
|
Else {
|
||||||
$svcState = $serviceStatus1.status
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>$svcState</B></td>"
|
|
||||||
}
|
$svcName = $serviceStatus1.name
|
||||||
}
|
$svcState = $serviceStatus1.status
|
||||||
######################################################
|
|
||||||
####################Netlogons status##################
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> $svcState </B></td>"
|
||||||
add-type -AssemblyName microsoft.visualbasic
|
}
|
||||||
$cmp = "microsoft.visualbasic.strings" -as [type]
|
}
|
||||||
$sysvol = start-job -scriptblock {dcdiag /test:netlogons /s:$($args[0])} -ArgumentList $DC
|
|
||||||
wait-job $sysvol -timeout $timeout
|
####################Netlogons status##################
|
||||||
if($sysvol.state -like "Running")
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
{
|
|
||||||
Write-Host $DC `t Netlogons Test TimeOut -ForegroundColor Yellow
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>NetlogonsTimeout</B></td>"
|
$sysvol = start-job -scriptblock {dcdiag /test:netlogons /s:$($args[0])} -ArgumentList $DC
|
||||||
stop-job $sysvol
|
|
||||||
}
|
Wait-Job $sysvol -timeout $timeout
|
||||||
else
|
|
||||||
{
|
If ($sysvol.state -like "Running") {
|
||||||
$sysvol1 = Receive-job $sysvol
|
Write-Host $DC `t Netlogons Test TimeOut -ForegroundColor Yellow
|
||||||
if($cmp::instr($sysvol1, "passed test NetLogons"))
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Netlogons </B></td>"
|
||||||
{
|
Stop-Job $sysvol
|
||||||
Write-Host $DC `t Netlogons Test passed -ForegroundColor Green
|
}
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>NetlogonsPassed</B></td>"
|
Else {
|
||||||
}
|
$sysvol1 = Receive-job $sysvol
|
||||||
else
|
|
||||||
{
|
If ($cmp::instr($sysvol1, "passed test NetLogons")) {
|
||||||
Write-Host $DC `t Netlogons Test Failed -ForegroundColor Red
|
Write-Host $DC `t Netlogons Test passed -ForegroundColor Green
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>NetlogonsFail</B></td>"
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Netlogons OK </B></td>"
|
||||||
}
|
}
|
||||||
}
|
Else {
|
||||||
########################################################
|
Write-Host $DC `t Netlogons Test Failed -ForegroundColor Red
|
||||||
####################Replications status##################
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Netlogons Echec </B></td>"
|
||||||
add-type -AssemblyName microsoft.visualbasic
|
}
|
||||||
$cmp = "microsoft.visualbasic.strings" -as [type]
|
}
|
||||||
$sysvol = start-job -scriptblock {dcdiag /test:Replications /s:$($args[0])} -ArgumentList $DC
|
|
||||||
wait-job $sysvol -timeout $timeout
|
####################Replications status##################
|
||||||
if($sysvol.state -like "Running")
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
{
|
|
||||||
Write-Host $DC `t Replications Test TimeOut -ForegroundColor Yellow
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>ReplicationsTimeout</B></td>"
|
$sysvol = start-job -scriptblock {dcdiag /test:Replications /s:$($args[0])} -ArgumentList $DC
|
||||||
stop-job $sysvol
|
|
||||||
}
|
Wait-Job $sysvol -timeout $timeout
|
||||||
else
|
If ($sysvol.state -like "Running") {
|
||||||
{
|
Write-Host $DC `t Replications Test TimeOut -ForegroundColor Yellow
|
||||||
$sysvol1 = Receive-job $sysvol
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Replications </B></td>"
|
||||||
if($cmp::instr($sysvol1, "passed test Replications"))
|
Stop-Job $sysvol
|
||||||
{
|
}
|
||||||
|
Else {
|
||||||
|
$sysvol1 = Receive-job $sysvol
|
||||||
|
|
||||||
|
If ($cmp::instr($sysvol1, "passed test Replications")) {
|
||||||
Write-Host $DC `t Replications Test passed -ForegroundColor Green
|
Write-Host $DC `t Replications Test passed -ForegroundColor Green
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>ReplicationsPassed</B></td>"
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Replications OK </B></td>"
|
||||||
}
|
}
|
||||||
else
|
Else {
|
||||||
{
|
Write-Host $DC `t Replications Test Failed -ForegroundColor Red
|
||||||
Write-Host $DC `t Replications Test Failed -ForegroundColor Red
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Replications Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>ReplicationsFail</B></td>"
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
########################################################
|
####################Services status##################
|
||||||
####################Services status##################
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
add-type -AssemblyName microsoft.visualbasic
|
|
||||||
$cmp = "microsoft.visualbasic.strings" -as [type]
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
$sysvol = start-job -scriptblock {dcdiag /test:Services /s:$($args[0])} -ArgumentList $DC
|
$sysvol = start-job -scriptblock {dcdiag /test:Services /s:$($args[0])} -ArgumentList $DC
|
||||||
wait-job $sysvol -timeout $timeout
|
|
||||||
if($sysvol.state -like "Running")
|
Wait-Job $sysvol -timeout $timeout
|
||||||
{
|
|
||||||
Write-Host $DC `t Services Test TimeOut -ForegroundColor Yellow
|
If ($sysvol.state -like "Running") {
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>ServicesTimeout</B></td>"
|
Write-Host $DC `t Services Test TimeOut -ForegroundColor Yellow
|
||||||
stop-job $sysvol
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Services </B></td>"
|
||||||
}
|
Stop-Job $sysvol
|
||||||
else
|
}
|
||||||
{
|
Else {
|
||||||
$sysvol1 = Receive-job $sysvol
|
$sysvol1 = Receive-job $sysvol
|
||||||
if($cmp::instr($sysvol1, "passed test Services"))
|
|
||||||
{
|
If ($cmp::instr($sysvol1, "passed test Services")) {
|
||||||
Write-Host $DC `t Services Test passed -ForegroundColor Green
|
Write-Host $DC `t Services Test passed -ForegroundColor Green
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>ServicesPassed</B></td>"
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Services OK</B></td>"
|
||||||
}
|
}
|
||||||
else
|
Else {
|
||||||
{
|
Write-Host $DC `t Services Test Failed -ForegroundColor Red
|
||||||
Write-Host $DC `t Services Test Failed -ForegroundColor Red
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Services Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>ServicesFail</B></td>"
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
########################################################
|
####################Advertising status##################
|
||||||
####################Advertising status##################
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
add-type -AssemblyName microsoft.visualbasic
|
|
||||||
$cmp = "microsoft.visualbasic.strings" -as [type]
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
$sysvol = start-job -scriptblock {dcdiag /test:Advertising /s:$($args[0])} -ArgumentList $DC
|
$sysvol = start-job -scriptblock {dcdiag /test:Advertising /s:$($args[0])} -ArgumentList $DC
|
||||||
wait-job $sysvol -timeout $timeout
|
|
||||||
if($sysvol.state -like "Running")
|
Wait-Job $sysvol -timeout $timeout
|
||||||
{
|
|
||||||
Write-Host $DC `t Advertising Test TimeOut -ForegroundColor Yellow
|
If ($sysvol.state -like "Running") {
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>AdvertisingTimeout</B></td>"
|
Write-Host $DC `t Advertising Test TimeOut -ForegroundColor Yellow
|
||||||
stop-job $sysvol
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Advertising Timeout </B></td>"
|
||||||
}
|
Stop-Job $sysvol
|
||||||
else
|
}
|
||||||
{
|
Else {
|
||||||
$sysvol1 = Receive-job $sysvol
|
$sysvol1 = Receive-job $sysvol
|
||||||
if($cmp::instr($sysvol1, "passed test Advertising"))
|
|
||||||
{
|
If ($cmp::instr($sysvol1, "passed test Advertising")) {
|
||||||
Write-Host $DC `t Advertising Test passed -ForegroundColor Green
|
Write-Host $DC `t Advertising Test passed -ForegroundColor Green
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>AdvertisingPassed</B></td>"
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Advertising OK </B></td>"
|
||||||
}
|
}
|
||||||
else
|
Else {
|
||||||
{
|
Write-Host $DC `t Advertising Test Failed -ForegroundColor Red
|
||||||
Write-Host $DC `t Advertising Test Failed -ForegroundColor Red
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Advertising Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>AdvertisingFail</B></td>"
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
########################################################
|
####################FSMOCheck status##################
|
||||||
####################FSMOCheck status##################
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
add-type -AssemblyName microsoft.visualbasic
|
|
||||||
$cmp = "microsoft.visualbasic.strings" -as [type]
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
$sysvol = start-job -scriptblock {dcdiag /test:FSMOCheck /s:$($args[0])} -ArgumentList $DC
|
$sysvol = start-job -scriptblock {dcdiag /test:FSMOCheck /s:$($args[0])} -ArgumentList $DC
|
||||||
wait-job $sysvol -timeout $timeout
|
|
||||||
if($sysvol.state -like "Running")
|
Wait-Job $sysvol -timeout $timeout
|
||||||
{
|
|
||||||
Write-Host $DC `t FSMOCheck Test TimeOut -ForegroundColor Yellow
|
If ($sysvol.state -like "Running") {
|
||||||
Add-Content $report "<td bgcolor= 'Yellow' align=center><B>FSMOCheckTimeout</B></td>"
|
Write-Host $DC `t FSMOCheck Test TimeOut -ForegroundColor Yellow
|
||||||
stop-job $sysvol
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Check FSMO </B></td>"
|
||||||
}
|
Stop-Job $sysvol
|
||||||
else
|
}
|
||||||
{
|
Else {
|
||||||
$sysvol1 = Receive-job $sysvol
|
$sysvol1 = Receive-job $sysvol
|
||||||
if($cmp::instr($sysvol1, "passed test FsmoCheck"))
|
|
||||||
{
|
If ($cmp::instr($sysvol1, "passed test FsmoCheck")) {
|
||||||
Write-Host $DC `t FSMOCheck Test passed -ForegroundColor Green
|
Write-Host $DC `t FSMOCheck Test passed -ForegroundColor Green
|
||||||
Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>FSMOCheckPassed</B></td>"
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B>Check FSMO OK </B></td>"
|
||||||
}
|
}
|
||||||
else
|
Else {
|
||||||
{
|
Write-Host $DC `t FSMOCheck Test Failed -ForegroundColor Red
|
||||||
Write-Host $DC `t FSMOCheck Test Failed -ForegroundColor Red
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Check FSMO Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center><B>FSMOCheckFail</B></td>"
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
########################################################
|
Else {
|
||||||
|
Write-Host $DC `t $DC `t Ping Fail -ForegroundColor Red
|
||||||
}
|
Add-Content $Report " <td bgcolor= 'GainsBoro' align=center> <B> $Identity </B></td>"
|
||||||
else
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
{
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Write-Host $DC `t $DC `t Ping Fail -ForegroundColor Red
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'GainsBoro' align=center> <B> $Identity</B></td>"
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
}
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
|
||||||
Add-Content $report "<td bgcolor= 'Red' align=center> <B>Ping Fail</B></td>"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Add-Content $report "</tr>"
|
Add-Content $Report " </tr>"
|
||||||
|
|
||||||
############################################Close HTMl Tables###########################
|
############################################Close HTMl Tables###########################
|
||||||
Add-content $report "</table>"
|
Add-Content $Report " </table>"
|
||||||
Add-Content $report "</body>"
|
Add-Content $Report " </body>"
|
||||||
Add-Content $report "</html>"
|
Add-Content $Report "</html>"
|
||||||
|
|
||||||
|
|
||||||
########################################################################################
|
|
||||||
#############################################Send Email#################################
|
#############################################Send Email#################################
|
||||||
|
If (($Smtphost) -and ($MailReport) -and ($From)) {
|
||||||
if(($Smtphost) -and ($EmailReport) -and ($from)){
|
[string]$body = Get-Content $Report
|
||||||
[string]$body = Get-Content $report
|
Send-MailMessage -SmtpServer $Smtphost -From $From -To $MailReport -Subject "Active Directory Health Monitor" -Body $body -BodyAsHtml
|
||||||
Send-MailMessage -SmtpServer $Smtphost -From $from -To $EmailReport -Subject "Active Directory Health Monitor" -Body $body -BodyAsHtml
|
|
||||||
}
|
}
|
||||||
####################################EnD#################################################
|
|
||||||
########################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user