I am trying to combine some info from our Active directory – computer names, description and the user samAccountName since we have users that have nonstandard login names.
We have for computer description “FirstName LastName” of the user that is using it and I was able to put out the Computer name and description.
But when I try to extract the login with the following script:
Get-ADComputer -Filter 'name -like "wks-*"' -properties description|
sort name|
%{"$($_.name),$($_.description),$(get-aduser -Filter {name -eq $_.description})"}
I just get the distinguish name for the given user.
Is there a way to return by default a different property? If not how can such a thing can be accomplished?
I tried adding .samaccountname at the end like this:
%{"$($_.name),$($_.description),$(get-aduser -Filter {name -eq $_.description}).samaacountname"}
but this just concatenate it to the distinguished name.
If I understand the question, then I think this would do what you want: