lazywinadmin / Monitor-ADGroupMembership

PowerShell script to monitor Active Directory groups and send an email when someone is changing the membership
MIT License
264 stars 61 forks source link

OneReport not quite right, sends blank reports #33

Open cryptonym64 opened 6 years ago

cryptonym64 commented 6 years ago

OneReport option will always send, even if none of the monitored groups have changed. This results in an email that says to "check the attachments", but has no attachments and is otherwise blank.

I moved the $ScriptPathOneReport assignment up a few lines and added detection to the OneReport sending code where it was previously only checking for if ($OneReport) {. Changed it to:

   $ScriptPathOneReport = $ScriptPath + "\OneReport"
   if($OneReport -and (Test-Path -Path $ScriptPathOneReport) -and ((Get-ChildItem $ScriptPathOneReport).count -gt 0)) {

This seems to have fixed it.