Thanks guys.  I found a script online that I was able to adjust a bit and it 
worked.

Still amazes me how many ways there are to skin a cat with Powershell.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Emin
Sent: Thursday, July 28, 2016 8:15 AM
To: [email protected]
Subject: Re: [NTSysADM] Powershell help

Hi,
Replace
-Properties userPrincipalName
by
-Properties *
http://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx

Get-ADUser -Filter * -SearchBase 'ou=xxx,ou=xxx,ou=xxx,dc=xxx,dc=local' 
-Properties * |
% {
 try {
  $_ | Set-ADUser -UserPrincipalName "$($_.EmailAddress)" -ErrorAction Stop
 } catch {
  Write-Warning -Message "Failed because $($_.Exception.Message)"
 }
}

On Wed, Jul 27, 2016 at 4:27 AM, Heaton, Joseph@Wildlife 
<[email protected]<mailto:[email protected]>> wrote:
I’m trying to set my users’ userPrincipalName to be the same as the 
emailaddress.  Here’s the snippet I’m trying to use:

Get-ADUser -Filter * -SearchBase 'ou=xxx,ou=xxx,ou=xxx,dc=xxx,dc=local' 
-Properties userPrincipalName | foreach { Set-ADUser $_ -UserPrincipalName 
"$($_.emailaddress)"}

I know that last bit is wrong, I keep getting errors.  I’ve tried as-is, and 
$($_.emailaddress)}

Anyone have any advice?  I can’t think of any other attribute that has the same 
format as the email address (first.last).



Joe Heaton
Information Technology Operations Branch
Data and Technology Division
CA Department of Fish and Wildlife
1700 9th Street, 3rd Floor
Sacramento, CA  95811
Desk:  (916) 323-1284<tel:%28916%29%20323-1284>

Every Californian should conserve water.  Find out how at:
[SaveOurWater_Logo]<http://saveourwater.com/>
SaveOurWater.com<http://saveourwater.com/> · 
Drought.CA.gov<http://drought.ca.gov/>


Reply via email to