Active Directory
--
Questions
--
Followers
Top Experts
DCdiag /test:DNS /e /v
Repadmin /replsum /bysrc /bydest /sort:delta
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
@echo off
echo.
echo Gathering Report for DCLIST = %1
echo.
Echo Report for DCLIST = %1 >Â replreport.txt
echo. >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering Verbose Replication and Connections
echo Verbose Replication and Connections >>Â replreport.txt echo. >>Â replreport.txt
repadmin /showrepl %1 /all >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering Bridgeheads
echo Bridgeheads >>Â replreport.txt
echo. >>Â replreport.txt
repadmin /bridgeheads %1 /verbose >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering ISTG
echo ISTG >>Â replreport.txt
echo. >>Â replreport.txt
repadmin /istg %1 >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering DRS Calls
echo Outbound DRS Calls >>Â replreport.txt
echo. >>Â replreport.txt
repadmin /showoutcalls %1 >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering Queue
echo Queue >>Â replreport.txt
echo. >>Â replreport.txt
repadmin /queue %1 >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering KCC Failures
echo KCC Failures >>Â replreport.txt
echo. >>Â replreport.txt
repadmin /failcache %1 >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering Trusts
echo Trusts >>Â replreport.txt
echo. >>Â replreport.txt
repadmin /showtrust %1 >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering Replication Flags
echo Replication Flags >>Â replreport.txt
echo. >>Â replreport.txt
repadmin /bind %1 >>Â replreport.txt
echo. >>Â replreport.txt
echo Gathering Replication Summary
echo Replication Summary >>Â replreport.txt
repadmin /replsum /bysrc /bydest /sort:delta %1 >>Â replreport.txt
echo. >>Â replreport.txt
echo Done.
Â
 I also need the DCdiag /test:dns /e /v to output to a text file.  Once the two txt files are generated, I need them to be emailed to a group daily.  Is this doable?
get-pssnapin -reg | add-pssnapin -ea 0
DCdiag /test:DNS /e /v >c:\DCDIAG.txt
Repadmin /replsum /bysrc /bydest /sort:delta >c:\ReplTest.txt
  $filename1 = "C:\DCDiag.txt"
  $filename2 = "C:\Repltest.txt"
 Â
  $smtpServer = "smtp.mydomain.int"
  $msg = new-object Net.Mail.MailMessage
  $att1 = new-object Net.Mail.Attachment($filen
  $att2 = new-object Net.Mail.Attachment($filen
  $smtp = new-object Net.Mail.SmtpClient($smtpS
  $msg.From = "itadmin@mydomain.int"
  #$msg.To.Add("itadmin@mydo
  $msg.To.Add("itadmin@mydom
  $msg.Subject = "Domain DCDIAG and Repadmin reports"
  $msg.Body = "This is the report of blah blah blah.....`r`n`r`n"
  $msg.Attachments.Add($att1
  $msg.Attachments.Add($att2
  $smtp.Send($msg)
  $att.dispose()
  }






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
get-pssnapin -reg | add-pssnapin -ea 0
DCdiag /test:DNS /e /v >c:\ADHealthCheck\DNSrepor
c:\ADHealthCHeck\Rplreport
  $filename1 = "C:\ADHealthCheck\DNSrepor
  $filename2 = "C:\ADHealthCheck\replrepo
 Â
  $smtpServer = "exchange.ehm.com"
  $msg = new-object Net.Mail.MailMessage
  $att1 = new-object Net.Mail.Attachment($filen
  $att2 = new-object Net.Mail.Attachment($filen
  $smtp = new-object Net.Mail.SmtpClient($smtpS
  $msg.From = "ADHealthCheck@ehm.com"
  #$msg.To.Add("ADHealthChec
  $msg.To.Add("ADHealthCheck
  $msg.Subject = "Active Directory Health Check Reports"
  $msg.Body = "This is a report of DNS and Replication Health Checks.....`r`n`r`n"
  $msg.Attachments.Add($att1
  $msg.Attachments.Add($att2
  $smtp.Send($msg)
  $att.dispose()
  }
 How do I run it in powershell?






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Set-ExecutionPolicy -ExecutionPolicy remotesigned
However, I gave this script a try and it seems that the script is not given enough time to grab the txt files with results. It will need a modification.
Will take a look.
  {
  $filename1 = "C:\ADHealthCheck\DNSrepor
  $filename2 = "C:\ADHealthCheck\replrepo
  .
  .
  .
  .

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
$SMTPserver = "mysmtp.nowhere.now"
$fileattachment = "c:\\boot.ini"
$from = "hans@nowhere.now"
$to = "somebody@somewhere.org"
$subject = "PowerShell Test"
$emailbody = "this is my very first email send through PowerShell 1.0"
$mailer = new-object Net.Mail.SMTPclient($SMTPs
$msg = new-object Net.Mail.MailMessage($from
$attachment = new-object Net.Mail.Attachment($filea
$msg.attachments.add($atta
$mailer.send($msg)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
$SMTPserver = "mysmtp.nowhere.now"
$fileattachment = "c:\\boot.ini"
$from = "hans@nowhere.now"
$to = "somebody@somewhere.org"
$subject = "PowerShell Test"
$emailbody = "this is my very first email send through PowerShell 1.0"
$mailer = new-object Net.Mail.SMTPclient($SMTPs
$msg = new-object Net.Mail.MailMessage($from
$attachment = new-object Net.Mail.Attachment($filea
$msg.attachments.add($atta
$mailer.send($msg)
$SMTPserver = "mysmtp.nowhere.now"
$fileattachment = "c:\\boot.ini"
$from = "hans@nowhere.now"
$to = "somebody@somewhere.org"
$subject = "PowerShell Test"
$emailbody = "this is my very first email send through PowerShell 1.0"
$mailer = new-object Net.Mail.SMTPclient($SMTPs
$msg = new-object Net.Mail.MailMessage($from
$attachment = new-object Net.Mail.Attachment($filea
$msg.attachments.add($atta
$mailer.send($msg)
I get emails. Â So smtp is working. Â What's the next step?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
$fileattachment1 = "c:\\DCDIAG.txt"
$fileattachment1 = "c:\\RepAdmin.txt"
$from = "hans@nowhere.now"
$to = "somebody@somewhere.org"
$subject = "PowerShell Test"
$emailbody = "this is my very first email send through PowerShell 1.0"
$mailer = new-object Net.Mail.SMTPclient($SMTPs
$msg = new-object Net.Mail.MailMessage($from
$attachment = new-object Net.Mail.Attachment($filea
$attachment = new-object Net.Mail.Attachment($filea
$msg.attachments.add($atta
$mailer.send($msg)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
http://www.vistax64.com/powershell/176479-emailing-multiple-files.html
Active Directory
--
Questions
--
Followers
Top Experts
Active Directory (AD) is a Microsoft brand for identity-related capabilities. In the on-premises world, Windows Server AD provides a set of identity capabilities and services, and is hugely popular (88% of Fortune 1000 and 95% of enterprises use AD). This topic includes all things Active Directory including DNS, Group Policy, DFS, troubleshooting, ADFS, and all other topics under the Microsoft AD and identity umbrella.