SOLVED

New to Powershell - Moving Values Between Attributes

Copper Contributor

Hello,

 

I am new to these forums and Power Shell in general so please bare with my newness :)

 

I think I will start with a little bit of history since since it may help as I maybe missing something all together.


I am a New Server Administrator.

 

We have moved from Exchange on Prem to o365 Off Prem while still using AD On Prem.

 

That being said our signature solution changed to a cloud based solution (Exlaimer Cloud) and some of the AD Attributes we were using Microsoft does not Sync over to to o365. 

 

Example:

 

Our call manager uses telephone number which we have as an extension  XXXX

so we use the OTHER Telephone to make it XXX.XXX.XXX for display on our signatures.

 

otherFacsimileTelephoneNumber  is however NOT Synced over fro On Prem AD

 

We are thinking / working towards possibly moving to Azure AD which will fix this however, that is awhile away.

 

So I am trying to move some attributes over... however I can not figure it out.

 

Can anyone assist?

 

I am trying to do the following...

 

Target = Users in Specified OU  (for this example lets say FQDN / DOMAIN / Computer Users / HR / John Doe )

 

Move Attributes:

Attribute 1 -

from otherTelephoneNumber

to homePhone

 

Attribute 2 - 

from otherFacsimileTelephoneNumber

to pager

 

Attribute 3 - 

from info

to ipPhone

 

I know this wont be the CLEANEST for Active Directory, but with the sync options that actually work with o365... I am left without many options.

7 Replies

Hello @dwmoreau,

From information provided in your post I am assuming you are using AzureADConnect to sync users and their attributes from on-prem AD to AzureAD.

You can add additional attributes to the sync using ADConnect tool:
" ...you can add missing attribute by synchronizing it from your on-premises Active Directory (AD) to Azure Active Directory (Azure AD)."

 

Please follow steps outlined here.

 

Hope that helps.

@AndySvints 

 

I have tried AD Connect SYNC but it does NOT Syn what Microsoft has listed it should.  For instance OtherFacsimileTelephoneNumber.  I opened a case with Microsoft support and I got the following response. (after months of them asking for logs and everything else).

 

--------------------------------------------

Hello David,

 

This is regarding service request ticket number 17421263.


As per the output we are only able to see the FacsimileTelephoneNumber   if that us been set in the AD.

Department                     : XXXXXXXXXXX

DirSyncEnabled                 : True

DisplayName                    : XXXXXXXXXXX

FacsimileTelephoneNumber       :

GivenName                      : XXXXXXXX

We were unable to see the OtherFacsimileTelephoneNumber    anywhere in the office 365 which is an by design.

Please let me know if you have any more query or concern for the same.

Thank you for using Microsoft Product Support and Microsoft Products.

Warm Regards,

Tulshiram Kolekar

Microsoft Technical Support

------------------------------------------------

 

I then asked them what they DO Sync and they could not give me an answer.

 

-----------------------------------------------

 

Hello David,

This is in reference to Service Request: 17421263.

We have highlighted this issue to our senior escalation team and they are checking for the attribute which sync to office 365.

Once we get the list of the attribute which shows in the office 365 we will provide same to you.

As of now we don’t have any ETA for the same. Once we get any update from them we will let you know the same.

As of now we will proceed with the temporally closer on this case if you still have any issue please do reply to this email so we can get back to you.

Feel free to drop in an e-mail to me in case of any query or help required and will call you back in no time and make sure that the support delivered to you will be no less than excellent stuff.

Your satisfaction is our key concern and will make sure that our future endeavor with regards to any query will be of remembrance and will impact our relation in a positive way.

 

---------------------------------------

 

I mean if you KNOW this works somehow, I am all ears, I would rather not have to go through an edit what we already have in AD.

 

- Thanks!

@dwmoreau,

I see what you are saying.

You are correct even though attribute otherFacsimileTelephoneNumber is synced via ADConnect Tool to AzureAD it is not exposed to be accessible via management endpoints and even Graph API. Basically it is there but you cannot read/get it. 

 

In terms of moving attributes values in local AD from one to another it can be completed using Set-ADObject cmdlet.

You just need to be mindful about the attributes value restrictions.

For example otherFacsimileTelephoneNumber  is a collection and pager is a string.

Also make sure that you are understand the priority of the actions of Set-ADObject:

  1. Remove
  2. Add
  3. Replace
  4. Clear

So in order to move attribute from otherFacsimileTelephoneNumber  to pager you would do something along those lines:

Get-ADUser myTestUser | 
%{Set-ADObject -Identity $_.DistinguishedName -Replace @{pager=$_.otherFacsimileTelephoneNumber | select -First 1} -Clear otherFacsimileTelephoneNumber }

Move the value from otherFacsimileTelephoneNumber  to pager  and clear otherFacsimileTelephoneNumber .

 

More Details: Set-ADObject Documentation

Hope that helps. 

 

 

 

@AndySvints 

 

That's awesome!

 

Thanks for baring with my explanation.

 

Given you example, I should be able to use it and even use it to construct some of my own with a known working example.

 

One thing if you don't mine, how could I target a specific OU instead of a single user?

@AndySvints 

 

Thanks for taking the time with me here -

 

I tried this with my own test user and from what i can see it appears as though it is seeing the information as blank.

 

I also added a snippet of the error & of the AD User screens.

 

Capture2.PNGCapture.PNG

best response confirmed by dwmoreau (Copper Contributor)
Solution

@dwmoreau,

My bet, in my code snippet I did not get all needed user attributes with Get-ADUser.

By default get ad user gets 10 user attributes and otherFacsimileTelephoneNumber is not one of them.

Try this:

Get-ADUser myTestUser -Properties otherFacsimileTelephoneNumber | %{Set-ADObject -Ident
ty $_.DistinguishedName -Replace @{pager=$_.otherFacsimileTelephoneNumber | select -First 1} -Clear otherFacsimileTeleponeNumber }

Also keep in mind that the snippet I am providing can be used for one as well as for all users:

Get-ADUser -filter * -Properties otherFacsimileTelephoneNumber | #... everything else

 

Hope that helps.

A@AndySvints 

 

This help immensely and I was able to get that snippet working after adding a h in the last telephone, I only knew to look because I do that alot. :)

 

I was able to use that to work with the next two I needed using the following.

 

Get-ADUser dmoreau -Properties otherTelephone | %{Set-ADObject -Identity $_.DistinguishedName -Replace @{homePhone=$_.otherTelephone | select -First 1} -Clear otherTelephone }

&

Get-ADUser dmoreau -Properties info | %{Set-ADObject -Identity $_.DistinguishedName -Replace @{ipPhone=$_.info | select -First 1} -Clear info }

 

I tried searching but obviously most people don't need to do this.  is there a way to split the notes lines up by a comma or something?

 

Example it takes the note:

 

LINE 1

LINE 2

 

and makes it:

 

LINE 1LINE 2

 

 

- Thanks again!

1 best response

Accepted Solutions
best response confirmed by dwmoreau (Copper Contributor)
Solution

@dwmoreau,

My bet, in my code snippet I did not get all needed user attributes with Get-ADUser.

By default get ad user gets 10 user attributes and otherFacsimileTelephoneNumber is not one of them.

Try this:

Get-ADUser myTestUser -Properties otherFacsimileTelephoneNumber | %{Set-ADObject -Ident
ty $_.DistinguishedName -Replace @{pager=$_.otherFacsimileTelephoneNumber | select -First 1} -Clear otherFacsimileTeleponeNumber }

Also keep in mind that the snippet I am providing can be used for one as well as for all users:

Get-ADUser -filter * -Properties otherFacsimileTelephoneNumber | #... everything else

 

Hope that helps.

View solution in original post