'Powershell Command Gather OU List

I'm attempting to gather information about a list of devices from AD. I want to go through each component and filter out the information to only show if the device is within a specific OU. In this case it would be all computers without a mdt component. So far I'm able to pull the information but it list each component as a line of text and I'm looking to just list if the devices are listed a part of the specific OU.

$workstation = "WSAPTKFT00003"

$properties = (get-adcomputer $workstation -Properties *).memberof

$properites_clean = $properties -replace("cn=","") -replace(",OU=Components,OU=ClientManagement,DC=*,DC=rl,DC=*,DC=com","") -replace(",OU=EntitlementGroups,OU=ClientManagement,DC=*,DC=rl,DC=*,DC=com","")

foreach($component in $properites_clean)
    {
        If($component -like '*windows_upgrd*')
            {
                "$workstation has windows upgrade entitled." | Out-File C:\LocalFiles\windows_upgrd.txt -Append
            }
        Else
            {
                "$workstation does not have windows upgrade entitled." | Out-File C:\LocalFiles\windows_upgrd.txt -Append
            }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source