2

First of all this is my first post, so if there is something I should know about the procedure on Stackoverflow please let me know.

Now, let's get to my problem with powershell. I am creating a powershell script that will retrieve SAMaccountname and ipphone attribute, then export them to csv file.

Import-Module activedirectory

Get-Aduser -filter {ipphone -like "*"} -properties samaccountname,ipphone | select name,samaccountname,ipphone | export-csv "C:\output.csv" -NoTypeInformation

The result is:

namme,samaccount,ipphone

Now... I need a column with domain/samaccountname format instead of standalone samaccountname. What can I do to achieve this?

1 Answer 1

3

Add a calculated property to the property list when using select:

... | select name,samaccountname,ipphone,@{Label='Username';Expression={"DOMAINNAME\$($_.SamAccountName)"}}
Sign up to request clarification or add additional context in comments.

2 Comments

@Jona I'm afraid I don't understand the question. Are you trying to merge the properties of two different objects into one object?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.