alanlam123
asked on
How to write the DCDIAG powershell
Hi expert
How to write a Dcdiag script and send email and report about all servers in Forest
How to write a Dcdiag script and send email and report about all servers in Forest
ASKER
Hi Expert
Please comment the following and do i miss out the anything?
#DcDiag script to send email report about all servers in Forest#
$users = "alan.lam@zuji.com"
$fromemail = "alan.lam@zuji.com"
$server = "mail.webjet.co.sg"
$subject = "DC Diag Report for all DCs - $ ((Get-Date).ToShortDateStr ing())"
Get-ADDomainController -Filter * | ForEach-Object {
$DCDiag = DcDiag /a /s:$($_.Hostname)
$email =@{
From = $fromemail
To = $users
Subject = $subject
SMTPServer = $server
Boday = ($DCDiag | Out-String)
}
Send-MailMessage @email
}
Please comment the following and do i miss out the anything?
#DcDiag script to send email report about all servers in Forest#
$users = "alan.lam@zuji.com"
$fromemail = "alan.lam@zuji.com"
$server = "mail.webjet.co.sg"
$subject = "DC Diag Report for all DCs - $ ((Get-Date).ToShortDateStr
Get-ADDomainController -Filter * | ForEach-Object {
$DCDiag = DcDiag /a /s:$($_.Hostname)
$email =@{
From = $fromemail
To = $users
Subject = $subject
SMTPServer = $server
Boday = ($DCDiag | Out-String)
}
Send-MailMessage @email
}
Why not use the script that is the focus of that link I posted? It is already to go, you just need to check the email info?
Also, this email would be quite long and user/reader unfriendly.
In your array, "Boday" should be "Body".
I recommend using the script in the link provided above.
Dan
Also, this email would be quite long and user/reader unfriendly.
In your array, "Boday" should be "Body".
I recommend using the script in the link provided above.
Dan
ASKER
Thanks it really works the only issue that i have that not able to send email to my inbox.
cheers
cheers
If you were to explain, in more detail, the errors sending the email is causing, I am sure it can be resolved.
Dan
Dan
ASKER
There is no error and let me show you the following;
$reportpath = ".\ADReport.htm"
if((test-path $reportpath) -like $false)
{
new-item $reportpath -type file
}
$smtphost = "mail.webjet.co.au"
$from = "alan.lam@zuji.com"
$email1 = "alan.lam@zuji.com"
$timeout = "60"
$reportpath = ".\ADReport.htm"
if((test-path $reportpath) -like $false)
{
new-item $reportpath -type file
}
$smtphost = "mail.webjet.co.au"
$from = "alan.lam@zuji.com"
$email1 = "alan.lam@zuji.com"
$timeout = "60"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nil
Dan