Powershell where-object syntax - Hyphen in attribute

Viewed 2587

I'm using the below to target only relevant users.

Get-ADUser -Filter * -SearchBase $TargetOU -Properties * | Where-Object {$_.adminDescription -eq "Azure_Sync" -and $_.proxyAddresses -notlike "sip*" -and $_.sn -ne $null -and $_.msRTCSIP-PrimaryUserAddress -ne $null

However, it's not liking the last one $_.msRTCSIP-PrimaryUserAddress. The "-" is breaking things here so how do I go about using this attribute in the same way as the others?

1 Answers

You can add quotes around the property like

$_."msRTCSIP-PrimaryUserAddress"
Related