Get last logged on user email
Hi all,
Havent found anything yet searching aroung the web I post the question here.
I would like to get the last logged on user email address but it is a field I haven't found anywhere in PDQ database.
I have a dynamic collection of PCs not scanned since 7 days, in my infrastructure means roaming users that do not raise the VPN connection for the time set in the collection.
I would like to automatize in PDQ Inventory a package that runs a script targeting that collection and send an email to the users inviting them to connect their PCs to the corporate network via VPN.
Do you have any advice on this?
Thanks,
kind regards
Comments
I've found this way, running the following script to get the email address as "logged on user":
$searcher = [adsisearcher]"(samaccountname=$env:USERNAME)"
$searcher.FindOne().Properties.mail
Then via a custom SQL report I extract the list of disconnected PCs in the dynamic collection on a CSV file containing the hostname, username, and email address.
And as last step I've configured a scheduled task on PDQ server to run a powershell script that send emails to the users listed in the CSV file.