1

Hi!

Some of my users have lastname firstname in AD and I'd like to clean this up. Tried with the following snippet:

get-QADUser user | Set-QADUser -DisplayName "$($_.FirstName + ' '+$_.LastName)"

but

get-QADUser user | select displayname

shows blank Displayname

What am I doing wrong here?

Sune
  • 3,080
  • 16
  • 53
  • 64

1 Answers1

1

In this way it works

$user = get-QADUser user

Set-QADUser -identity $user -DisplayName ( $($user.firstname) + " " + $($user.lastname) )

In your way I think the pipe doesn't work as aspected. Maybe try to do a foreach-object

CB.
  • 58,865
  • 9
  • 159
  • 159
  • Thank you! Works great. Would love to know what was wrong though:) – Sune Oct 03 '12 at 10:27
  • @Sune Have you tested your code using a foreach-object after the pipe? – CB. Oct 03 '12 at 11:17
  • No I haven't (I quickly moved on to the next problem;)). But isn't there only one object? – Sune Oct 04 '12 at 07:47
  • @Sune. Yes there'is only one, but from the piping point of view this can works: `-DisplayName ( $_.firstname) + " " + $_.lastname) )` but I've not tested it. – CB. Oct 04 '12 at 08:22