2
votes

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

1 Answers

2
votes

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

... | select name,samaccountname,ipphone,@{Label='Username';Expression={"DOMAINNAME\$($_.SamAccountName)"}}