Handling attributes with hyphens in PowerShell

Sometimes we need working with PowerShell objects which have attributes with hyphens. That can be a bit difficult as PowerShell assumes hyphens are used with operators and parameters.

Below is an example on how to get around this, and rename the attribute:

 

 

$Users = Get-AdUser -Filter * -Property "msDS-ResultantPSO" | Select name, @{Name="ResultantPSO";Expression={$_."msDS-ResultantPSO"}}

 

 

Published by

Henrik Damgaard

Hi I’m Henrik and I write this blog based on useful topics I find interesting – mostly covering some of my technical interests : System Center Operations Manager (SCOM), BizTalk, Windows Server, PowerShell, SQL server, Internet Information Services, PHP and .NET I am currently holding a position as System Administrator with focus on Microsoft server products.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.