Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Powershell script that sends an email upon login with the username

There is a need for a Powershell script which will trigger on login, which will send the name of the username which just logged in, to a specified email address.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of E=mc2

ASKER

Will this send the username of the user that just logged in?  Or does one have to specify the user name?
It will automatically retrieve the username and computername of the user that just logged in, and send the email.
Avatar of E=mc2

ASKER

Thank you, I will try it and report back.
Avatar of E=mc2

ASKER

This does not seem to work.    Which variables do I input?
I wonder if you might have anti-virus software that is blocking the email from sending?

We use McAfee anti-virus, and need to enable the "mass mail" rule to allow a machine to send emails through the SMTP server.

The variables you need to change are these three:
$strSMTPServer = "yourmailserver"
$strFrom = "logins@domain.com"
$strTo = "admin@domain.com"

where the $strSMTPServer is the name of your SMTP server (that may need to allow relay from your machines sending email), and the other two are your "from" and "to" addresses.

Rob.
Avatar of E=mc2

ASKER

I will try again.. and report back.