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]> 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
>
>
>
> Every Californian should conserve water.  Find out how at:
>
> [image: SaveOurWater_Logo] <http://saveourwater.com/>
>
> SaveOurWater.com <http://saveourwater.com/> · Drought.CA.gov
> <http://drought.ca.gov/>
>
>
>

Reply via email to