Forum Discussion
New to Powershell - Moving Values Between Attributes
- Jun 19, 2020
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 elseHope that helps.
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!
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:
- Remove
- Add
- Replace
- 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.
- dwmoreauJun 19, 2020Copper Contributor
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.
- AndySvintsJun 19, 2020Iron Contributor
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 elseHope that helps.
- dwmoreauJun 19, 2020Copper Contributor
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!
- dwmoreauJun 19, 2020Copper Contributor
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?