I want a powershell script to give me a csv list of the DisplayName and MemberOf for rdp users that are not disabled for an audit I'm doing. Here is what I've tried so far, but the results aren't showing the MemberOf as I hoped. I think becase it's a collection or something. What would be a working script that would show MemberOf correctly. I'd be happy if it was multiple records per DisplayName, or even all MemberOf combined on one record per Display name.
Bonus points if the MemberOf only has the OU part.
Get-ADUser -Filter {(msTSManagingLS -like '*' -and msTSLicenseVersion -like '*') -or (terminalServer -like '*')} -Properties * | Where-Object {$_.Enabled -like “true”} | Select-Object -Property DisplayName, memberof |export-csv -Path c:\spla\out.csv Current Output
#TYPE Selected.Microsoft.ActiveDirectory.Management.ADUser "DisplayName","memberof" ,"Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben01","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben02","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben04","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben05","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben06","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben07","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben03","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Ben08","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "ralliance04","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "towncenter05","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Shannon","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "towncenter04","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Shelley","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "towncenter03","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Jessica","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Randi","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" "Kristin","Microsoft.ActiveDirectory.Management.ADPropertyValueCollection"