Some attributes that you can pull from Active Directory may have a hyphen in them. That makes them a bit difficult to work with in PowerShell. When PowerShell sees the hyphen, it assumes that you just put a cmdlet in the wrong place. To handle a hyphenated attribute, you need to rename that property. For this example, I am going to use the msDS-ResultantPSO. Take a look at the code below. $UserList = Get-AdUser -filter * -property msDS-ResultantPSO | Select name , @ { Name = "ResultantPSO" ;Expression = { $_ . "msDS-ResultantPSO" }} The @ symbol tells us we are about to rename a property. In the first section inside double quotes, we declare the new name of the property. In the Expression portion, we tell PowerShell what attribute we want to rename. Notice we use the $_. to tell PowerShell to look at the current object passed to it for this attribute. From here on out, this property is now referred to as msDsResultantPSO...
Welcome to the blogsite of MCTExpert. I am a Microsoft Certified Trainer. Here you will find the real questions that are asked to me by my students.