Need help on sending emails to inactive users

Welcome Forums General PowerShell Q&A Need help on sending emails to inactive users

  • This topic has 5 replies, 3 voices, and was last updated 1 month ago by
    Participant
    .
Viewing 5 reply threads
  • Author
    Posts
    • #257537
      Participant
      Topics: 2
      Replies: 5
      Points: 37
      Rank: Member

      Hi Guys,

      I’m trying to send email to inactive users in my organization. I’m new to PowerShell, so need your help. I was able to reuse the script to pull out the users with an email attribute who didn’t log in for 45 days and I managed to create the script for sending emails. It is perfectly working.

      Now I need to pass the mail attribute output to a variable and use that variable to send emails.

      And I noticed few users don’t have an email attribute, so I want to notify their mangers.

      When I run the below command, I’m getting the output of the manager name in distinguished format (“CN=Mamilla\, Sampath,OU=LS Users,DC=Contoso,DC=COM”). I’m trying to fetch the manager  SAMaccountname and email address.

      I did the below customization it didn’t work.

      Need your help.

      ————–email script—————————————————-

      • This topic was modified 1 month ago by grokkit. Reason: code formatting - please read the guide
    • #257870
      Participant
      Topics: 16
      Replies: 1794
      Points: 3,300
      Helping Hand
      Rank: Community Hero

      One option is to write that logic into an EmailTo with a calculated property:

      Still would be wise to wrap an if around that mail send if ($_.EmailTo) {… as a manager could be null.

    • #257912
      Participant
      Topics: 2
      Replies: 5
      Points: 37
      Rank: Member

       

    • #258782
      Participant
      Topics: 2
      Replies: 5
      Points: 37
      Rank: Member

      Thanks everyone!

    • #258991
      Participant
      Topics: 25
      Replies: 197
      Points: 718
      Helping Hand
      Rank: Major Contributor

      Just a logic point, not an issue with your script. But if your users aren’t logging on, how do you expect them to recieve/read email?

      might want to send to the manager and cc the user to ensure it gets visibility 🙂

    • #259006
      Participant
      Topics: 2
      Replies: 5
      Points: 37
      Rank: Member

      Hi David,

      I thought about it. That’s the reason I also want to pull out the manager email address.

      If you see the line number 16 in my original question, i tried to extract but failed. I don’t know the logic on how to extract it.

      I got a priority requirement in my office, so working on that. I thought of starting this thread again on Monday. If you are able to help me with on pulling the manager email address along with user email address, that will be great help. Thank you.

       

       

Viewing 5 reply threads
  • You must be logged in to reply to this topic.