Hi,
Last Friday i was working on one script, that script send an email to a “Service Desk” system. But that script required an email id of the sending user. So that if someone replied to that email from service desk software it should goes to users email id. This is global script and we can’t embedded a hard username value in to this.
Even i don’t want to use “Active Directory” module to this script.
Then i come with an simple idea
I ideas was to use “+” operator and use username “windows environments”
We can get a logged in user name of the logged in user by accessing $env:username
I am logged in as user “Aman.Dhally”
Ok, my domain name for email ids is “Localmail.com”
now we can add both these values “$env:username” and my “domain name” using joining plus “+” operator.
and in a result we go “username + '@Domain name” and the output will be the complete email id of the user.
We are saving the result of below to the variable $email so that we can use then anywhere in the script.
$email = "$env:username" + "@localmail.com"
Finally i got a users email ID
Thanks
Aman Dhally
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.