-1

Sometimes you want to write an email to all users that are currently in the office. You could now just insert all the email addresses into a mail but you might not know who's in the office your you forget someone.

Another solution would it be to write the email to a security group. But this will also sent the mail to users that are on vacation.

I know that you can see the sessions on a fileserver as well as the opened files. Can I use this information to get all the users that are currently logged in? And how could I open a mail with all those users filled into the "to" field of a mail (maybe with some kind of batch file)?

2ndkauboy
  • 73
  • 3
  • 14
  • 1
    What's wrong with sending the email to all users, whether they're logged in or not? – joeqwerty Sep 09 '10 at 11:55
  • I don't want to send a mail to 50 users if only 5 are in the office. And it is also annoying if someone returns from vacation and has many mails that are out of date. It will also not waste space at the exchange data store. – 2ndkauboy Sep 09 '10 at 11:57
  • 3
    Exchange leverages Single-Instance storage on the mailbox stores. A single email duplicated out to all staff residing in a single mailbox store will only occupy a single message worth of space. In 2007 and 2010 that only applies to attachments, but the text portion of an email usually trivial. – Chris Thorpe Sep 09 '10 at 12:00
  • You wouldn't waste space in the exchange store. http://en.wikipedia.org/wiki/Single-instance_storage - edit : You beat me to it by 5 seconds Chris! :) – Bryan Sep 09 '10 at 12:00
  • 3
    It seems like a lot of effort to deal with a situation that is so inconsequential, IMO. If you're really worried about it why not invest in a corporate instant messaging solution? – joeqwerty Sep 09 '10 at 12:04
  • I just wanted to know if it is possible. Implementing a instant messaging solution would be a little to much as we usually communicate through email. – 2ndkauboy Sep 09 '10 at 12:22
  • Which version(s) of Exchange are you running, and what's the functional level of the AD forest? – Adam Thompson Dec 30 '14 at 12:56

2 Answers2

2

You would have to poll every workstation and server in your environment for the current logged-in-user, and from there, pull the email address from each AD User object. I would recommend scripting this solution.

But then again, this is a lot of wasted effort when sending to the Everyone group is not that much inconvenience.

gWaldo
  • 11,957
  • 8
  • 42
  • 69
  • ...and even then, what about people who have locked their computer prior to leaving instead of logging out? I like the corporate IM solution joeqwerty suggested above. – EEAA Sep 09 '10 at 12:18
  • It must not be bullet proof. Just some little help for the many non-technical users that do not know how to write to a group or how to use an IM. And with the IM solution you might have the problem, that some users might have switched it off. But they can't switch off email completely (except of not opening Outlook the whole day). – 2ndkauboy Sep 09 '10 at 12:24
  • Can you provide me a resource on how to get that information. I am not a full time administrator, so some useful tutorials about getting data from the AD would be nice. – 2ndkauboy Sep 09 '10 at 12:26
  • Thanks for pointing out the IM mention above. I +1'd it. – gWaldo Sep 09 '10 at 12:40
  • 1
    @Kau-Boy, The Microsoft Technet Script Center Repository is http://gallery.technet.microsoft.com/ScriptCenter/en-us . The search feature is reasonably good. I must say, however, that if you don't have the requisite knowledge of how to code already (which I highly encourage), I really do recommend a broadcast email. The time you'll spend getting proficient will far outweigh the combined deleting of messages... – gWaldo Sep 09 '10 at 12:43
2

This is quite easy. AD has a 'lastloggedontimestamp'.

I use the Quest AD CmdLets still, but you could re-jig this to work with the standard ActiveDirectory module.

Basically you get 'today' and then scan for anyone with the last logontimestemp that matches today.

$today = (Get-Date).day
get-qaduser | where { $_.lastlogontimestamp.day -eq $today } | select samaccountname, lastlogontimestamp, Email

Its not perfect, and I can think of improvements but it fits your requirements

Patrick
  • 1,280
  • 1
  • 15
  • 36
  • I want to give you points, but I don't want to up-vote this as an answer. So I'm just commenting that I love this solution. It's not *that* terrible to script this out in powershell. – Get-HomeByFiveOClock Dec 29 '14 at 20:11
  • [With default settings in place the lastLogontimeStamp will be 9-14 days behind the current date](http://blogs.technet.com/b/askds/archive/2009/04/15/the-lastlogontimestamp-attribute-what-it-was-designed-for-and-how-it-works.aspx) – Dusan Bajic Dec 29 '14 at 22:55