PowerShell 7.3 - scenarios with Select-Object and Custom Properties in Nested Objects
I'm collaborating on a project where I'm prototyping a solution and I'm working with an scenario where I'm trying to extract specific properties from nested objects using `Select-Object`, but I'm getting unexpected results. The code I wrote is intended to retrieve user details from Active Directory, but when I attempt to create a custom property that concatenates the first and last names, I receive an behavior. Here's the snippet of code I'm using: ```powershell $users = Get-ADUser -Filter * -Property GivenName, Surname, Department | Select-Object @{Name='FullName'; Expression={"$($_.GivenName) $($_.Surname)"}}, Department ``` When I run this, I get the following behavior message: ``` Select-Object : want to bind parameter 'Expression'. want to convert value "$($_.GivenName) $($_.Surname)" to type "System.Management.Automation.ScriptBlock". ``` I've tried a few variations, like using `ForEach-Object` to build an array of objects first and then selecting from that, but the behavior continues. My goal is to create a clean output that displays the full name along with their department without working with this binding scenario. Is there a best practice for handling custom properties like this in PowerShell 7.3, especially when working with nested properties? Any help would be greatly appreciated! I'm working on a CLI tool that needs to handle this. How would you solve this? This is my first time working with Powershell LTS. Could this be a known issue? This is happening in both development and production on CentOS.