forked from MicksITBlogs/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmailEnvVariable.ps1
28 lines (24 loc) · 1007 Bytes
/
EmailEnvVariable.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<#
.SYNOPSIS
Email Address Environment Variable
.DESCRIPTION
This script will assign the user's email address to the environment variable EmailAddress.
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.128
Created on: 10/12/2016 1:14 PM
Created by: Mick Pletcher
Filename: EmailEnvVariable.ps1
===========================================================================
.PARAMETER
A description of the parameter.
#>
[CmdletBinding()]
param ()
Import-Module ActiveDirectory
#Delete Environment Variable
[System.Environment]::SetEnvironmentVariable("EmailAddress", $null, 'User')
#Get the email address associated with the username
$EmailAddress = (Get-ADUser $env:USERNAME -Properties mail).mail
#Create a user based environment variable called email address
[System.Environment]::SetEnvironmentVariable("EmailAddress", $EmailAddress, 'User')