E-mail notification when new device gets added (Script 1) – PowerShell Script

This is part 1 of a two-part Script. The email ID you mention will get an email every time a new dev (a new computer account) gets added to the domain.

Syntax

$EventId = 4741

$A = Get-WinEvent -MaxEvents 1 -FilterHashTable @{Logname = “Security” ; ID = $EventId}
$Message = $A.Message
$EventID = $A.Id
$MachineName = $A.MachineName
$Source = $A.ProviderName

$MyEmail = “XYZ@gmail.com” ##Sender email id
$MyPass = Get-Content “C:\Users\Administrator\Documents\password.txt”| ConvertTo-SecureString -AsPlainText -Force ##filepath of sender email account password

Download Full Script

EventID: 4741

Source: Microsoft-Windows-Security-Auditing

MachineName:

Message: A computer account was created.

Subject:

Security ID:

Account Name:

Account Domain:

Logon ID:

New Computer Account:

Security ID:

Account Name:

Account Domain:

Share Script:

Purpose:By running this script you'll get an email notification every time a new device gets created in the domain
Modification:Add SMTP, Email ID
Type:PowerShell (.ps1)
Compatibility:Run with PowerShell
Tags:Notification, E-mail, New Device, New Computer account
Reference link: