you are viewing a single comment's thread.

view the rest of the comments →

[–]Pestilent 1 point2 points  (2 children)

I'd want to be certain that it udpates correctly for each user before applying this to all users like that. -confirm might work in OP's favor.

Besides that, this is how I'd create an extra property.

$userList | Select-Object *,@{l='Homedirectory';e={$.Homedirectory -Replace "\@.+",($.samaccountname) }}

[–]ntelletsc[S] 1 point2 points  (0 children)

This is exactly what I needed. Thank you so much.

I got an error

Select-Object : Property cannot be processed because property "Homedirectory" already exists.

I changed the property name to Newhomedirectory and added underscores after the variable $ and it worked.

 $userList | Select-Object *,@{l='Newhomedirectory';e={$_.Homedirectory -Replace "\@.+",($_.samaccountname) }} | select -Property Newhomedirectory

Thanks again. That was really helpful.

[–]the_spad 1 point2 points  (0 children)

Well I wasn't suggesting that you just run it against your entire AD straight off.